There is no such thing as a battery light, but only the voltage system.
That means you have an electrical problem.
Without enough voltage, the fuel injection can not work, so the engine dies.
You could have thrown a serpentine belt.
The alternator could be bad.
You could have worn insulation on a wire that is shorting out to ground.
You could have a loose battery terminal clamp.
There are other possibilities, but this is a good start.
Next would be to put a voltmeter between battery terminals and see if you have 12.5 volts with engine off, and over 13.5 with the engine running.
But if the electrical warning light is coming on because the engine dies first, that is normal.
The light should come on if the key is on and alternator not putting out.
Then you need to find out why the engine is dying, such as clogged fuel filter, loose manifold hose, etc.