Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Breakpoint at exception in Eclipse - how to examine Exception object?

Tags:

I feel like I'm missing something very simple here. I have Eclipse set up to break on all exceptions. So, let's say that it breaks on an AssertationFailedException. The Debug window will show that thread suspended and has the following data:

Thread [Thread-1] (Suspended (exception AssertionFailedException)) 
    ContactManager.addContact(String) line: 93  
    ContactManager$ContactDataCallback.dispatch(String, Element, ClientConnector) line: 118 
    PacketHandler.handle(FractusPacket) line: 173   
    ServerConnection.syncProcess(FractusMessage) line: 122  
    ServerConnection.run() line: 248    
    Thread.run() line: 636

However, the text that I'm looking for, such as: "Getter called outside realm of observable org.eclipse.core.databinding.observable.set.WritableSet@4b7361e2", is not available until I step through the exception (thus propagating it all the way up the stack) where it outputs the type of the exception, the text (which is the part that I want) and the stack trace.

How can I examine the "AssertationFailedException" (or any other exception) in order to get the message with which the exception was constructed? Of course I'm in the Debug perspective.

like image 734
Hut8 Avatar asked Aug 10 '10 21:08

Hut8


People also ask

How do you check breakpoints in Eclipse?

To define a breakpoint in your source code, right-click in the left margin in the Java editor and select Toggle Breakpoint. Alternatively, you can double-click on this position. The Breakpoints view allows you to delete and deactivate Breakpoints and modify their properties.

How do I fix Java exception breakpoint in Eclipse?

You can fix this immediately by opening the Markers view and delete the Java Exception Breakpoints. However, to permanently remove this type of breakpoints, you have to go to the Java Debug options and uncheck the "Suspend excecution on uncaught exceptions" option.

How do you step through a breakpoint in Eclipse?

Use F5 to trace into, F6 to step over, CTRL-SHIFT-B to set/remove breakpoints.


2 Answers

There is an option in the Eclipse Preferences that allows inspecting of the thrown exception:

Check Java -> Debug -> Open popup when suspended on exception

With this option there will be a popup allowing inspection of the exception.

Strange that this option is not checked by default as it is very useful !

like image 108
Michel Avatar answered Sep 19 '22 09:09

Michel


In the debug view, click on the thread producing the exception.

Here is the image

like image 26
cul-de-chaoui Avatar answered Sep 21 '22 09:09

cul-de-chaoui