Search code examples
java-8eclipse-rcplogbacke4

Logging all uncaught exceptions Eclipse E4


I'm logging all my caught exceptions in my database using Logback. Now I need to log all the exceptions that are not caught. How can I log all the exceptions in E4 that are thrown and not handled?


Solution

  • If you put a class implementing org.eclipse.e4.ui.internal.workbench.swt.IEventLoopAdvisor in the application context its eventLoopException method will be called for each unhandled exception.

    The @PostContextCreate method of your LifeCycle class is a good place to do this:

    @PostContextCreate
    public void postContextCreate(final IEclipseContext context)
    {
      context.set(IEventLoopAdvisor.class, yourEventLoopClass);
    
      ...
    }
    

    Note that this is an internal interface but this usage seems to be valid.