Note: this entire discussion is exclusively about unchecked exceptions. Checked exceptions have nothing to do with what I am talking about here.
So, I have my Intellij IDEA debugger configured to only break on unhandled exceptions.
Of course this would not work without some extra love, because language constructs such as try-with-resources catch and rethrow, thus causing the debugger to break not at the point where the exception was thrown, but instead at the point where the exception is rethrown, which is useless, but I have gone through the trouble of putting in all the necessary extra love (I will spare you from the details) and I have gotten things to work reasonably well.
So, when an exception is thrown anywhere within my code, I never have to guess what went wrong by poring through post-mortem stack traces in logs; I can see what went wrong by having the debugger stop right at the throw statement.
This all works reasonably well for the most part; specifically, it works reasonably well for as long as all the code involved is my code. unfortunately, sometimes I also have to deal with other people's code.
When I call Jim's function, which in turn calls my function, and my function throws, then quite often this exception is not treated as an unhandled exception, because Jim's function quite often contains a try-catch. When this happens, and depending on what Jim does in his try-catch statement, the debugger will either stop somewhere within Jim's code, or it will not stop at all, and there will be a stack trace in the log if I am lucky. In either case, my goal will not be met: the debugger will not stop on the throw statement.
For example, if I register an observer with Swing, and Swing invokes my observer, and my observer throws an exception which is unhandled as far as I am concerned, the exception will certainly not be unhandled as far as Swing is concerned, because Swing has a try-catch at the very least in the main loop of its Event Dispatcher Thread. So, the debugger will never break on the throw statement.
So, my question is:
Is there anything I can do to convince the debugger to stop on exceptions that are unhandled as far as I am concerned?
To put it in different terms: is there any way to let the debugger know what the boundaries of my code are, so that it can stop on exceptions that cross those boundaries?
Please note that I may not necessarily have freedom to change the throw statement: I may in turn be invoking yet a third library, which may be throwing the exception, or I may be invoking some code of mine which is general purpose, so its throw statement needs to stay as it is, because there probably exists some test which exercises that code to ensure that it throws the expected exception under the right circumstances.
I am using IntelliJ IDEA, if that matters.