private static void reportUncaughtException( Throwable e, boolean reportSwallowedExceptionToBrowser) { if (Impl.uncaughtExceptionHandlerForTest != null) { Impl.uncaughtExceptionHandlerForTest.onUncaughtException(e); } UncaughtExceptionHandler handler = GWT.getUncaughtExceptionHandler(); if (handler != null) { if (handler == Impl.uncaughtExceptionHandlerForTest) { return; // Already reported so we're done. } // TODO(goktug): Handler might throw an exception but catching and reporting it to browser // here breaks assumptions of some existing hybrid apps that uses UCE for exception // conversion. We don't have an alternative functionality (yet) and it is too risky to include // the change in the release at last minute. handler.onUncaughtException(e); return; // Done. } // Make sure that the exception is not swallowed if (GWT.isClient() && reportSwallowedExceptionToBrowser) { reportToBrowser(e); } else { System.err.print("Uncaught exception "); e.printStackTrace(System.err); } }
@Override public void onUncaughtException(final Throwable e) { userHandlers.forEach(h -> h.accept(e)); oReplaced.ifPresent(h -> h.onUncaughtException(e)); }
@Override public void callback(final Message message) { final String errorTo = message.get(String.class, MessageParts.ErrorTo); if (errorTo == null || DefaultErrorCallback.CLIENT_ERROR_SUBJECT.equals(errorTo)) { final Throwable t = message.get(Throwable.class, MessageParts.Throwable); if (GWT.getUncaughtExceptionHandler() != null) { GWT.getUncaughtExceptionHandler().onUncaughtException(t); } else { managementConsole.displayError(message.get(String.class, MessageParts.ErrorMessage), message.get(String.class, MessageParts.AdditionalDetails), null); } } else { message.toSubject(errorTo); message.set(MessageParts.ErrorTo, null); message.sendNowWith(ClientMessageBusImpl.this); } }
/** * Takes care of reporting exceptions to the console in hosted mode. * * @param listener the listener object to call back. * @param port argument from the callback. */ private static void onMessageImpl(MessageHandler messageHandler, MessageEvent event) { UncaughtExceptionHandler ueh = GWT.getUncaughtExceptionHandler(); if (ueh != null) { try { messageHandler.onMessage(event); } catch (Exception ex) { ueh.onUncaughtException(ex); } } else { messageHandler.onMessage(event); } }
@Override public void callback(final Message message) { final String errorTo = message.get(String.class, MessageParts.ErrorTo); if (errorTo == null || DefaultErrorCallback.CLIENT_ERROR_SUBJECT.equals(errorTo)) { final Throwable t = message.get(Throwable.class, MessageParts.Throwable); if (GWT.getUncaughtExceptionHandler() != null) { GWT.getUncaughtExceptionHandler().onUncaughtException(t); } else { managementConsole.displayError(message.get(String.class, MessageParts.ErrorMessage), message.get(String.class, MessageParts.AdditionalDetails), null); } } else { message.toSubject(errorTo); message.set(MessageParts.ErrorTo, null); message.sendNowWith(ClientMessageBusImpl.this); } }
/** * Takes care of reporting exceptions to the console in hosted mode. * * @param listener the listener object to call back. * @param port argument from the callback. */ private static void onMessageImpl(MessageHandler messageHandler, MessageEvent event) { UncaughtExceptionHandler ueh = GWT.getUncaughtExceptionHandler(); if (ueh != null) { try { messageHandler.onMessage(event); } catch (Exception ex) { ueh.onUncaughtException(ex); } } else { messageHandler.onMessage(event); } }
private <T> Promise<T> handleCatchBlockExceptions(final Object rejectedObject) { if (rejectedObject instanceof Error) { final Error error = (Error) rejectedObject; if (!(error.getObject() instanceof Message)) { GWT.getUncaughtExceptionHandler().onUncaughtException( new RuntimeException("Promise.Error did not contain a Message. " + "Something's not right.")); return resolve(); } DEFAULT_RPC_ERROR_CALLBACK.error((Message) error.getObject(), error.getThrowable()); return resolve(); } if (rejectedObject instanceof Throwable) { GWT.getUncaughtExceptionHandler().onUncaughtException((Throwable) rejectedObject); return resolve(); } return reject(rejectedObject); }
/** * Takes care of reporting exceptions to the console in hosted mode. * * @param listener the listener object to call back. * @param port argument from the callback. */ private static void onErrorImpl(ErrorHandler errorHandler, ErrorEvent event) { UncaughtExceptionHandler ueh = GWT.getUncaughtExceptionHandler(); if (ueh != null) { try { errorHandler.onError(event); } catch (Exception ex) { ueh.onUncaughtException(ex); } } else { errorHandler.onError(event); } }
/** * Methods fe(...) should be used from asynchronous contexts so as we can * catch the exception and send it to the GWT UncaughtExceptionHandler * They are intentionally final to avoid override them. */ public final void fe(com.google.gwt.dom.client.Element elem) { if (GWT.getUncaughtExceptionHandler() != null) { try { f(elem.<com.google.gwt.dom.client.Element> cast()); } catch (Exception e) { GWT.getUncaughtExceptionHandler().onUncaughtException(e); } return; } f(elem.<com.google.gwt.dom.client.Element> cast()); } }
/** * Takes care of reporting exceptions to the console in hosted mode. * * @param listener the listener object to call back. * @param port argument from the callback. */ private static void onErrorImpl(ErrorHandler errorHandler, ErrorEvent event) { UncaughtExceptionHandler ueh = GWT.getUncaughtExceptionHandler(); if (ueh != null) { try { errorHandler.onError(event); } catch (Exception ex) { ueh.onUncaughtException(ex); } } else { errorHandler.onError(event); } }
/** * process generic handler callback * * @param handler * @param properties * @param formatter */ @SuppressWarnings("rawtypes") // is ugly, but is a cyclic generic type, so suppressed protected static <E extends MapEvent> void onCallback(final MapHandler<E> handler, final Properties properties, final MapEventFormatter<E> formatter) { try { formatEvent(handler, properties, formatter); } catch (Throwable x) { GWT.getUncaughtExceptionHandler().onUncaughtException(x); } }
/** * If an uncaught exception handler has been registered, execute the Runnable * in a try/catch block and handle exceptions with the uncaught exception * handler. Otherwise, run the Runnable and do not catch exceptions. * * @param runnable The Runnable to execute. */ public static void runProtected(Runnable runnable) { UncaughtExceptionHandler handler = GWT.getUncaughtExceptionHandler(); if (handler != null) { try { runnable.run(); } catch (Throwable e) { handler.onUncaughtException(e); } } else { runnable.run(); } }
/** * If an uncaught exception handler has been registered, execute the Runnable * in a try/catch block and handle exceptions with the uncaught exception * handler. Otherwise, run the Runnable and do not catch exceptions. * * @param runnable The Runnable to execute. */ public static void runProtected(Runnable runnable) { UncaughtExceptionHandler handler = GWT.getUncaughtExceptionHandler(); if (handler != null) { try { runnable.run(); } catch (Throwable e) { handler.onUncaughtException(e); } } else { runnable.run(); } }
/** * Methods fe(...) should be used from asynchronous contexts so as we can * catch the exception and send it to the GWT UncaughtExceptionHandler * They are intentionally final to avoid override them. */ public final Object fe(Object... args) { if (GWT.getUncaughtExceptionHandler() != null) { try { return f(args); } catch (Exception e) { GWT.getUncaughtExceptionHandler().onUncaughtException(e); } return true; } return f(args); }
/** * process generic handler callback * * @param handler * @param properties * @param formatter */ @SuppressWarnings("rawtypes") // is ugly, but is a cyclic generic type, so suppressed protected static <E extends MapEvent> void onCallback(final MapHandler<E> handler, final Properties properties, final MapEventFormatter<E> formatter) { try { formatEvent(handler, properties, formatter); } catch (Throwable x) { GWT.getUncaughtExceptionHandler().onUncaughtException(x); } }
/** * Methods fe(...) should be used from asynchronous contexts so as we can * catch the exception and send it to the GWT UncaughtExceptionHandler * They are intentionally final to avoid override them. */ public final boolean fe(Event ev, Object... args) { if (GWT.getUncaughtExceptionHandler() != null) { try { return f(ev, args); } catch (Exception e) { GWT.getUncaughtExceptionHandler().onUncaughtException(e); } return true; } return f(ev, args); }
/** * If application has own uncaughtExceptionHandler delegates to that. Otherwise wraps exception into * UnhandledException and throws. * @param exception cause */ public void onUncaughtException(Throwable exception) { IncidentReport report = incidentReportFactory.createReport(exception); DeliveryQueue.instance().pushIncident(report); if (handler != null) { handler.onUncaughtException(exception); } else { throw new UnhandledException(exception); } }
public final void onFailure(Throwable reason) { reason.printStackTrace(); GWT.log("Run async failure", reason); if (tries-->0){ dispatch(); }else{ UncaughtExceptionHandler handler = GWT.getUncaughtExceptionHandler(); if (handler != null) handler.onUncaughtException(reason); } }
private void onFrameLoadAndCatch(UncaughtExceptionHandler handler) { try { onFrameLoadImpl(); } catch (Throwable e) { handler.onUncaughtException(e); } }
private boolean onFormSubmitAndCatch(UncaughtExceptionHandler handler) { try { return onFormSubmitImpl(); } catch (Throwable e) { handler.onUncaughtException(e); return false; } }