¿Cómo ver la excepción cuando no hay captura en Eclipse?

Is it possible to determine which exception was occurred when it was catched by finally ¿solamente?

Below is excerpt from standard ThreadPoolExecutor code:

    public void run() {
        try {
            Runnable task = firstTask;
            firstTask = null;
            while (task != null || (task = getTask()) != null) {
                task = null;
        } finally {

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.

preguntado el 30 de enero de 12 a las 19:01

... you can't. Put in a catch(Throwable t){t.printStackTrace;} if you want to see what the exception is. -

@bdares, this is library code and I don't want to recompile it -

2 Respuestas

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.

Respondido el 30 de enero de 12 a las 23:01

Ese seria el Breakpoints view. Check the view's toolbar for a J with an exclamation point. - Chris

Debugger already stops. I just need to know what exception caused it, read it message or disable stopping. - Suzan Cioc

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

Respondido el 30 de enero de 12 a las 23:01

The Example you posted is quite usesless. This is its output: You crashed thread Thread-3 Exception was: java.lang.RuntimeException: Thrown from Thread java.lang.RuntimeException: Thrown from Thread at de.utils.SetUncaughtExceptionHandler.run(SetUncaughtExceptionHandler.java:16) at java.lang.Thread.run(Thread.java:662) - Marvin Emil Brach

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.