ServiceExceptionHandler implements ServiceErrorHandler { @Override public void uncaughtException(Thread t, Throwable e) { log.error("uncaughtException from {}", t.getName(), e); exceptionList.add(e); }  @Override void uncaughtException(Thread t, Throwable e); Throwable getFirstThrowableException(); void clearExceptions(); @Deprecated void throwFirstException(); @Override void throwExceptionAsRequired();  }
@Test public void testUncaughtException() throws Exception { ServiceExceptionHandler handler = new ServiceExceptionHandler(); handler.uncaughtException(Thread.currentThread(), new ServiceException("first")); handler.uncaughtException(Thread.currentThread(), new ServiceException("second")); assertNotNull(handler.getFirstThrowableException()); assertEquals("first", handler.getFirstThrowableException().getMessage()); handler.clearExceptions(); assertNull(handler.getFirstThrowableException()); }