Hacker News new | ask | show | jobs
by wvenable 4012 days ago
This has nothing to do with exceptions. If some function updates half of some structure and then just returns due to a bug then you have an inconsistent state and no exceptions were involved at all. And your application keeps running in an inconsistent state.
1 comments

You can only recover from such errors locally. The local context is not available in a global exception handler.
If your code corrupted your data structure or a cosmic ray changed a bit, you're not recovering no matter what.
That's my point: in this situation, you can't display an error and keep going. How do you know that you are not in this situation when you catch an unknown exception?
But in the same situation the code might not trigger an exception and continue just the same. You've gained or lost nothing.

You have to assume that code cleans itself up as the stack unwinds. That should be normal operation whether or not you are using exceptions or not. If the exception is in the middle of modifying a data structure then the cleanup should ensure that data structure is either back into a stable state or destroyed completely.

> You have to assume that code cleans itself up as the stack unwinds.

Exceptions or not, if you have an unknown error condition, how can you assume anything?

I apologize for the delayed response.