Hello,
Is there a way to make a global exception-handler in Java. I want to use like this:
"When an exception is thrown somewhere in the WHOLE program, exit."
The handler may not catch exceptions thrown in a try-catch
body.
Martijn
Hello,
Is there a way to make a global exception-handler in Java. I want to use like this:
"When an exception is thrown somewhere in the WHOLE program, exit."
The handler may not catch exceptions thrown in a try-catch
body.
Martijn
Use Thread.setDefaultUncaughtExceptionHandler. See Rod Hilton's "Global Exception Handling" blog post for an example.
You can set the default UncaughtExceptionHandler , which will be used whenever a exception propegates uncaught throughout the system.
DefaultUncaughtExceptionHandler is the correct answer. It was revealed to me by Jeff Storey at this location, a few days ago. As u suspected, the "manually" caught exceptions will never be caught by this handler. However i got the following warning :
**- To be compliant to J2EE, a webapp should not use any thread.**
when i have checked my project against good-practice and recommended java coding style with PMD plug-in for Eclipse IDE.