I’ve said it a few times now: the Elixir way says not to worry much about code that crashes; instead, make sure the overall application keeps running.
This might sound contradictory, but really it is not.
Think of a typical application. If an unhandled error causes an exception to be raised, the application stops. Nothing else gets done until it is restarted. If it’s a server handling multiple requests, they all might be lost.
The issue here is that one error takes the whole application down.
But imagine that instead your application consists of hundreds or thousands of processes, each handling just a small part of a request. If one of those crashes, everything else carries on. You might lose the work it’s doing, but you can design your applications to minimize even that risk. And when that process gets restarted, you’re back running at 100%.
In the Elixir and OTP worlds, supervisors perform all of this process monitoring and restarting.