private void handleException(Throwable ex) { if (backgroundExceptionHandler != null) { try { backgroundExceptionHandler.uncaughtException(null, ex); } catch(Throwable ignore) { if (ex != ignore) { // OOME may be the same ex.addSuppressed(ignore); } } } }
@Override public void onFailure(Throwable t) { if (t instanceof CancellationException && isShutdown.get()) { LOG.info("AMReporter QueueDrainer exited as a result of a cancellation after shutdown"); } else { LOG.error("AMReporter QueueDrainer exited with error", t); Thread.getDefaultUncaughtExceptionHandler().uncaughtException(Thread.currentThread(), t); } } });
private void insertIntoPreemptionQueueOrFailUnlocked(TaskWrapper taskWrapper) { boolean added = preemptionQueue.offer(taskWrapper); if (!added) { LOG.warn("Failed to add element {} to preemption queue. Terminating", taskWrapper); Thread.getDefaultUncaughtExceptionHandler().uncaughtException(Thread.currentThread(), new IllegalStateException("Preemption queue full. Cannot proceed")); } }
static void handleError(Throwable ex) { Thread thread = Thread.currentThread(); Throwable t = unwrap(ex); Thread.UncaughtExceptionHandler x = thread.getUncaughtExceptionHandler(); if (x != null) { x.uncaughtException(thread, t); } else { log.error("Scheduler worker failed with an uncaught exception", t); } if (onHandleErrorHook != null) { onHandleErrorHook.accept(thread, t); } }
/** * The executor re-throws exceptions thrown by the task to the uncaught exception handler * so we only need to do anything if uncaught exception handler has not been se */ private void logAndHandle(Throwable t, boolean passToHandler) { if (Thread.getDefaultUncaughtExceptionHandler() == null) { LOG.error("Unhandled exception on thread {}", Thread.currentThread().getName(), t); } else { LOG.info("Unhandled exception on thread {}", Thread.currentThread().getName(), t); if (passToHandler) { Thread.getDefaultUncaughtExceptionHandler().uncaughtException(Thread.currentThread(), t); } } }
@Override public void uncaughtException(Thread thread, Throwable ex) { TinkerLog.e(TAG, "uncaughtException:" + ex.getMessage()); tinkerFastCrashProtect(); tinkerPreVerifiedCrashHandler(ex); ueh.uncaughtException(thread, ex); }
/** * Send @param t to the default uncaught exception handler, or log it if none such is set up */ public static void handleOrLog(Throwable t) { if (Thread.getDefaultUncaughtExceptionHandler() == null) logger.error("Error in ThreadPoolExecutor", t); else Thread.getDefaultUncaughtExceptionHandler().uncaughtException(Thread.currentThread(), t); }
private void givenUncaughtException(final KsqlException e) { ehCapture.getValue().uncaughtException(new Thread(), e); }
private IllegalStateException panic(IllegalStateException e) { if (backgroundExceptionHandler != null) { backgroundExceptionHandler.uncaughtException(null, e); } panicException = e; closeImmediately(); return e; }
@Test(expectedExceptions = RuntimeException.class) public void testUncaughtException() { Logger logger = Mockito.mock(Logger.class); Thread thread = new Thread(); thread.setName("foo"); RuntimeException runtimeException = new RuntimeException(); String errorMessage = String.format("Thread %s threw an uncaught exception: %s", thread, runtimeException); Mockito.doThrow(runtimeException).when(logger).error(errorMessage, runtimeException); Thread.UncaughtExceptionHandler uncaughtExceptionHandler = new LoggingUncaughtExceptionHandler(Optional.of(logger)); uncaughtExceptionHandler.uncaughtException(thread, runtimeException); } }
/** * End the application. */ private void endApplication(@Nullable Thread uncaughtExceptionThread, Throwable th) { final boolean letDefaultHandlerEndApplication = config.alsoReportToAndroidFramework(); final boolean handlingUncaughtException = uncaughtExceptionThread != null; if (handlingUncaughtException && letDefaultHandlerEndApplication && defaultExceptionHandler != null) { // Let the system default handler do it's job and display the force close dialog. if (ACRA.DEV_LOGGING) ACRA.log.d(LOG_TAG, "Handing Exception on to default ExceptionHandler"); defaultExceptionHandler.uncaughtException(uncaughtExceptionThread, th); } else { processFinisher.endApplication(); } }
public static void report(Throwable e){ if(e == null) return; try{ //debug(e); warn("reporting", Log.getStackTraceString(e)); if(eh != null){ eh.uncaughtException(Thread.currentThread(), e); } }catch(Exception ex){ ex.printStackTrace(); } }
@Override public final void run() { try { if (!mGifDrawable.isRecycled()) { doWork(); } } catch (Throwable throwable) { final Thread.UncaughtExceptionHandler uncaughtExceptionHandler = Thread.getDefaultUncaughtExceptionHandler(); if (uncaughtExceptionHandler != null) { uncaughtExceptionHandler.uncaughtException(Thread.currentThread(), throwable); } throw throwable; } }
@Override public void onSuccess(Object result) { if (isShutdown.get()) { LOG.info("Wait queue scheduler worker exited with success!"); } else { LOG.error("Wait queue scheduler worker exited with success!"); Thread.getDefaultUncaughtExceptionHandler().uncaughtException(Thread.currentThread(), new IllegalStateException("WaitQueue worked exited before shutdown")); } }
@Override public void onFailure(Throwable t) { LOG.error("Wait queue scheduler worker exited with failure!", t); Thread.getDefaultUncaughtExceptionHandler().uncaughtException(Thread.currentThread(), t); } }
private void reportException(@NonNull final Throwable throwable) { // Throw uncaught exception that will trigger the report system Thread.currentThread().getUncaughtExceptionHandler() .uncaughtException(Thread.currentThread(), throwable); } });
private void reportFailure(final Thread runner, final Throwable thrown) { if (thrown instanceof InterruptedException) { runner.interrupt(); } else { final Thread.UncaughtExceptionHandler ueh = runner.getUncaughtExceptionHandler(); if (ueh != null) { ueh.uncaughtException(runner, thrown); } } }
static void uncaught(@NonNull Throwable error) { Thread currentThread = Thread.currentThread(); UncaughtExceptionHandler handler = currentThread.getUncaughtExceptionHandler(); handler.uncaughtException(currentThread, error); }
static void uncaught(@NonNull Throwable error) { Thread currentThread = Thread.currentThread(); UncaughtExceptionHandler handler = currentThread.getUncaughtExceptionHandler(); handler.uncaughtException(currentThread, error); }
@Override public void accept(Throwable error) throws Exception { Thread.currentThread().getUncaughtExceptionHandler().uncaughtException(Thread.currentThread(), error); } });