Hacker News new | ask | show | jobs
by wallyhs 4012 days ago
You can only recover from such errors locally. The local context is not available in a global exception handler.
1 comments

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.