Gauge invariance, anomalies, and the chiral Schwinger model