Error handling like a three-prong outlet
For the first 50 years or so, this is what electrical outlets in homes looked like (at least in America and some other places):
This particular design allows 120V of electricity to power any electronic device with a plug of this shape, while the plastic and rubber protect our fragile meat-flesh from its consuming power. Ideally, electricity flows out of one end (the hot wire — usually black), through a device to power it, and flows out into the neutral wire (usually white). Like water flowing downhill. Does it work? Yes. Most of the time.
The reality is that electricity could go through anything that comes in contact with those wires, be it floors, walls, ceilings, furniture, pets—you name it. Yet it doesn’t, because the effort required for electricity to move through rubber, plastic, and wood is ~1,000,000,000,000,000,000,000× harder than to just move through the metal wiring. At least, it should be.
_However _(you probably saw this coming), there are some instances where electricity’s path from hot to neutral is not the path of least resistance. Sometimes this is because a pet chewed a cord and the wiring is exposed. Sometimes something breaks or overheats in a device. Sometimes it’s just cheap manufacturing. There are virtually infinite non-ideal scenarios where electricity doesn’t go where expect it to. And that usually leads to…
Often in software development, we write code for perfect scenarios that work most of the time. When everything behaves perfectly and users do what we expect them to, our application runs without errors. But often people may do silly things like have Null as their last name. Or enter a database query into a field.
For electricity, all we really needed to do to solve this problem is add a third prong: the ground. 99% of the time it isn’t needed, but for that 1% of the time something goes wrong, a ground wire provides electricity an escape route with a resistance so low that conceivably nothing would be an easier path. And even though ground prongs exist for < 1% of scenarios, they are a necessary part of every physical outlet and medium-to-large device plug.
Sure, sure—unless you’re the developer responsible for developing an Internet-capable fire sprinkler (which I wouldn’t wish upon any human), you’re not going to cause house fires if you don’t handle errors gracefully. But like a ground prong in an outlet, error handling should be so ingrained in your development process that to skip it should feel like using a cheater plug (TL;DR they’re bad and dangerous). You cheater.
Whatever you incorporate into your process, always write code that expects errors to arise.