Ruben Laguna's blog

Jul 25, 2007 - 1 minute read - Comments - details eclipse error errordialog exception java reporting stacktrace

Eclipse Error Reporting: Exception stacktrace details

I’m working with Eclipse 3.2.2 RCP right now and I’m getting an exception that I want to display on screen. I found in the eclipsepedia that we must use ErrorDialog to report errors:

try {
// ...
} catch (InvocationTargetException e) {
  IStatus status = new Status(IStatus.ERROR, Application.ID, 1, "Exception found.", e.getCause());
  ErrorDialog.openError(window.getShell(),"Error while loading file", null,status);                     
}

But using this code snippet will only print the e.getLocalizedMessage() in the Details pane of the ErrorDialog. See screenshot

noexceptiondetails.png

If you want to see the full stacktrace of the exception in the Details pane you have to implement your own ErrorDialog. Thus taking ErrorDialog as a base and modifiying it a little bit with the guidance found here I created ExceptionDetailsErrorDialog.java.

Using ExceptionDetailsErrorDialog instead of ErrorDialog shows the following dialog: exceptiondetails.png