4 ms·
A panic means your program has entered an invalid state. Continuing to run an arbitrarily broken program would be reckless, so crashing is the only option. Eve
by Mawr 3y ago
A panic means your program has entered an invalid state. Continuing to run an arbitrarily broken program would be reckless, so crashing is the only option.
Even if you could somehow prevent your program from crashing internally, it could be killed at any time by the environment it's running in, up to the cleaning lady tripping on the power cable.
That's why it doesn't make sense to try to prevent crashes. Instead, programs should be capable of resumption irrespective of when they were killed. Resumption should be facilitated by supervisors layered on top of the program, as needed.