Reputation: 30127
Is it possible to determine which exception was occurred when it was catched by finally
only?
Below is excerpt from standard ThreadPoolExecutor code:
public void run() {
try {
Runnable task = firstTask;
firstTask = null;
while (task != null || (task = getTask()) != null) {
runTask(task);
task = null;
}
} finally {
workerDone(this);
}
}
I.e. here is no catch
. My debugger stops on workerDone()
call indicating RuntimeException occurred, but since here is no exception variable I see no way to know error message or something.
Upvotes: 1
Views: 1181
Reputation: 804
Not only for eclipse. You can use the Thread.setUncaughtExceptionHandler(...) If you can recompile, then do it inside the 'run' method. If not, ASAIK, even if you do that in the main thread, you will catch the exceptions in the "inner" threads.
setUncaughtExceptionHandler Example
Upvotes: 1
Reputation: 198211
You should be able to add an "exception breakpoint" in the debugger for uncaught exceptions. Typically, this is a tab right next to the "variables" tab in the Debug perspective.
Upvotes: 3