Articles > Eclipse

This isn’t quite the solution, but this is a start. We register an additional logging mechanism to the Eclipse Platform which allows us to catch IStatuses that are thrown. However, since the Platform is running in a different thread, it will be difficult to pass information back to the original thread.

 * Before jumping into an Eclipse test, this method should be called
 * so we can catch any exceptions that occur during loading, and 
 * print them out to the log.
protected void addLogListener() {
  Platform.addLogListener(new ILogListener() {
    public void logging(IStatus status, String plugin) {
      // rethrow if exception is caught
      if (status.getSeverity() == IStatus.ERROR) {
        // JUnit won't actually catch this, because the Platform is
        // in a different thread. however we will still get the 
        // stack trace in System.err so this remains somewhat useful.
        throw new RuntimeException(status.getMessage(), status.getException());
      } else {        
        // otherwise just print out the error

Used in the IAML project.