Inspect thrown exception inside finally
Answered
This is one of those things that was trivial for me to do in Eclipse but I'm getting nowhere with searching for how to do this in IDEA.
When I'm stopped at a breakpoint and a thrown exception is on stack, but the execution hasn't yet reached the first catch block, how can I inspect that exception?
SSCCE:
try {
try {
Integer.parseInt("False"); // <- Assume this throws an exception with an important message
} finally {
System.out.println("1"); // <- Breakpoint here
}
} catch (NumberFormatException ex) {
System.out.println("2");
}
Please sign in to leave a comment.
Did you try exception breakpoints?
https://www.jetbrains.com/help/idea/creating-exception-breakpoints.html
Thanks for responding, Serge.
When making the SSCCE I forgot about exception breakpoints. In my application it's actually a bit more complicated. The inner try is a try-with-resource and doesn't normally have a finally (only added in a debug attempt). That method is in a Runnable called from an executor that catches any exception. What I saw was that the method ends without hiccup when I expected an `IOException` or similar.
In the end I found out that using `FileChannel.transferFrom` swallows the exception and just silently 'finishes' under certain conditions. See the catch code at the end of https://stackoverflow.com/q/24983596/1052284
With this knowledge the original question becomes invalid.