Finding swallowed exceptions or errors

To figure out how to identify swallowed Exceptions/Errors I wrote a test in Eclipse. I added conditional breakpoints on all Throwable constructors and printed out all stacktraces whenever any Throwable is constructed. It works, but you couldn't get at the message to print it since it is set as the last line of the Throwable constructor and the constructor message argument is not available to conditional breakpoint code.

If you don't care about Exception/Error messages, just call this.printStackTrace() in conditional breakpoints on all Throwable constructors and look for Exceptions/Errors that reported the Throwable constructor but not logged later. These are possible swallowed exception/error candidates.

As an alternative, copy the Throwable source code and instrument the constructor implementations. Then simply -Xbootclasspath/p: the implementation into the VM ahead of the default Java Throwable implementation. This would allow you to print the message and report all exceptions/errors without having to run in a debugger.

Comments

Popular posts from this blog

Sites, Newsletters, and Blogs

Oracle JDBC ReadTimeout QueryTimeout