private void setUncaughtExceptionHandler() { final UncaughtExceptionHandler replacedHandler = GWT.getUncaughtExceptionHandler(); GWT.setUncaughtExceptionHandler(new ErraiUncaughtExceptionHandler(replacedHandler)); }
public void testErraiUncaughtExceptionHandlerInvokesReplacedHandler() throws Exception { final ErraiUncaughtExceptionHandler erraiHandler = assertErraiHandlerSet(); assertTrue(testHandlerLog.isEmpty()); final Throwable t = new Throwable(); erraiHandler.onUncaughtException(t); assertEquals(1, testHandlerLog.size()); assertSame(t, testHandlerLog.get(0)); }
public void testDependentExceptionHandler() throws Exception { final ErraiUncaughtExceptionHandler erraiHandler = assertErraiHandlerSet(); assertTrue(uncaughtHandlersLogger.getLogged().isEmpty()); final ExceptionForDependentHandler e = new ExceptionForDependentHandler(); erraiHandler.onUncaughtException(e); assertTrue(uncaughtHandlersLogger.getLogged().isEmpty()); final DependentUncaughtExceptionHandler handler = IOCUtil.getInstance(DependentUncaughtExceptionHandler.class); erraiHandler.onUncaughtException(e); assertEquals(1, uncaughtHandlersLogger.getLogged().size()); assertSame(e, uncaughtHandlersLogger.getLogged().get(0)); IOCUtil.destroy(handler); uncaughtHandlersLogger.reset(); erraiHandler.onUncaughtException(e); assertTrue(uncaughtHandlersLogger.getLogged().isEmpty()); }
public void testPrivateExceptionHandler() throws Exception { final ErraiUncaughtExceptionHandler erraiHandler = assertErraiHandlerSet(); assertTrue(uncaughtHandlersLogger.getLogged().isEmpty()); final ExceptionForPrivateHandler e = new ExceptionForPrivateHandler(); erraiHandler.onUncaughtException(e); assertEquals(1, uncaughtHandlersLogger.getLogged().size()); assertSame(e, uncaughtHandlersLogger.getLogged().get(0)); }
public void testAppScopedExceptionHandler() throws Exception { final ErraiUncaughtExceptionHandler erraiHandler = assertErraiHandlerSet(); assertTrue(uncaughtHandlersLogger.getLogged().isEmpty()); final ExceptionForAppScopedHandler e = new ExceptionForAppScopedHandler(); erraiHandler.onUncaughtException(e); assertEquals(1, uncaughtHandlersLogger.getLogged().size()); assertSame(e, uncaughtHandlersLogger.getLogged().get(0)); }