Where to handle fatal exceptions

Posted by Stephen Swensen on Stack Overflow See other posts from Stack Overflow or by Stephen Swensen
Published on 2010-04-11T09:34:11Z Indexed on 2010/04/11 9:43 UTC
Read the original article Hit count: 271

Filed under:
|
|

I am considering a design where all fatal exceptions will be handled using a custom UncaughtExceptionHandler in a Swing application. This will include unanticipated RuntimeExceptions but also custom exceptions which are thrown when critical resources are unavailable or otherwise fail (e.g. a settings file not found, or a server communication error). The UncaughtExceptionHandler will do different things depending on the specific custom exception (and one thing for all the unanticipated), but in all cases the application will show the user an error message and exit. The alternative would be to keep the UncaughtExceptionHandler for all unanticipated exceptions, but handle all other fatal scenarios close to their origin.

Is the design I'm considering sound, or should I use the alternative?

© Stack Overflow or respective owner

Related posts about java

Related posts about exceptions