简体   繁体   中英

How to watch exception when there is no catch in Eclipse?

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);
        }
    }

Ie 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.

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM