Tabnine Logo
Thread$UncaughtExceptionHandler
Code IndexAdd Tabnine to your IDE (free)

How to use
Thread$UncaughtExceptionHandler
in
java.lang

Best Java code snippets using java.lang.Thread$UncaughtExceptionHandler (Showing top 20 results out of 2,295)

origin: Tencent/tinker

@Override
public void uncaughtException(Thread thread, Throwable ex) {
  Log.e(TAG, "TinkerUncaughtHandler catch exception:" + Log.getStackTraceString(ex));
  ueh.uncaughtException(thread, ex);
origin: org.apache.hadoop/hadoop-common

  exception);
if (delegate != null) {
 delegate.uncaughtException(thread, exception);
origin: stackoverflow.com

defaultUEH.uncaughtException(t, e);
origin: fusesource/mqtt-client

  refiller.run();
} catch (Throwable e) {
  Thread.currentThread().getUncaughtExceptionHandler().uncaughtException(Thread.currentThread(), e);
origin: fusesource/mqtt-client

private void handleFatalFailure(Throwable error) {
  if( failure == null ) {
    failure = error;
    
    mqtt.tracer.debug("Fatal connection failure: %s", error);
    // Fail incomplete requests.
    ArrayList<Request> values = new ArrayList(requests.values());
    requests.clear();
    for (Request value : values) {
      if( value.cb!= null ) {
        value.cb.onFailure(failure);
      }
    }
    ArrayList<Request> overflowEntries = new ArrayList<Request>(overflow);
    overflow.clear();
    for (Request entry : overflowEntries) {
      if( entry.cb !=null ) {
        entry.cb.onFailure(failure);
      }
    }
    
    if( listener !=null && !disconnected ) {
      try {
        listener.onFailure(failure);
      } catch (Exception e) {
        Thread.currentThread().getUncaughtExceptionHandler().uncaughtException(Thread.currentThread(), e);
      }
    }
  }
}
origin: Rukey7/MvpApp

  /**
   * 这个是最关键的函数,当程序中有未被捕获的异常,系统将会自动调用#uncaughtException方法
   * thread为出现未捕获异常的线程,ex为未捕获的异常,有了这个ex,我们就可以得到异常信息。
   */
  @Override
  public void uncaughtException(Thread thread, Throwable ex) {
    ex.printStackTrace();
    if (!_handleException(ex) && mDefaultCrashHandler != null) {
      // 如果用户没有处理则让系统默认的异常处理器来处理
      mDefaultCrashHandler.uncaughtException(thread, ex);
    } else {
      try {
        Thread.sleep(3000);
      } catch (InterruptedException e) {
        Log.e(TAG, "error : ", e);
      }
      // 退出程序,注释下面的重启启动程序代码
//        android.os.Process.killProcess(android.os.Process.myPid());
//        System.exit(1);

      // 重新启动程序,注释上面的退出程序
      Intent intent = new Intent();
      intent.setClass(mContext, SplashActivity.class);
      intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
      mContext.startActivity(intent);
      android.os.Process.killProcess(android.os.Process.myPid());
    }

  }

origin: iSoron/uhabits

  @Override
  public void uncaughtException(@Nullable Thread thread,
                 @Nullable Throwable ex)
  {
    if (ex == null) return;

    try
    {
      ex.printStackTrace();
      new AndroidBugReporter(activity).dumpBugReportToFile();
    }
    catch (Exception e)
    {
      e.printStackTrace();
    }

//        if (ex.getCause() instanceof InconsistentDatabaseException)
//        {
//            HabitsApplication app = (HabitsApplication) activity.getApplication();
//            HabitList habits = app.getComponent().getHabitList();
//            habits.repair();
//            System.exit(0);
//        }

    if (originalHandler != null)
      originalHandler.uncaughtException(thread, ex);
  }
}
origin: aa112901/remusic

if (!handleException(ex) && mDefaultHandler != null) {
  mDefaultHandler.uncaughtException(thread, ex);
} else {
  try {
origin: smuyyh/BookReader

/**
 * 当UncaughtException发生时会转入该函数来处理
 */
@Override
public void uncaughtException(Thread thread, Throwable ex) {
  if (!handleException(ex) && mDefaultHandler != null) {
    //如果用户没有处理则让系统默认的异常处理器来处理
    mDefaultHandler.uncaughtException(thread, ex);
  } else {
    DownloadBookService.cancel(); // 取消任务
    LogUtils.i("取消下载任务");
    new Thread(new Runnable() {
      @Override
      public void run() {
        Looper.prepare();
        ToastUtils.showSingleToast("哎呀,程序发生异常啦...");
        Looper.loop();
      }
    }).start();
    try {
      Thread.sleep(3000);
    } catch (InterruptedException e) {
      LogUtils.e("CrashHandler.InterruptedException--->" + e.toString());
    }
    //退出程序
    android.os.Process.killProcess(android.os.Process.myPid());
    System.exit(1);
  }
}
origin: apache/storm

this.onKill.uncaughtException(this, e);
origin: cymcsg/UltimateAndroid

/**
 * Caught Exception
 */
@Override
public void uncaughtException(Thread thread, Throwable ex) {
  if (!handleException(ex) && mDefaultHandler != null) {
    mDefaultHandler.uncaughtException(thread, ex);
  } else {
    try {
      Thread.sleep(100);
    } catch (InterruptedException e) {
      Logs.e("error : ", e);
    }
    Logs.d("uncaught exception is catched!");
    System.exit(0);
    android.os.Process.killProcess(android.os.Process.myPid());
  }
}
origin: robovm/robovm

/**
 * Handles uncaught exceptions. Any uncaught exception in any {@code Thread}
 * is forwarded to the thread's {@code ThreadGroup} by invoking this
 * method.
 *
 * <p>New code should use {@link Thread#setUncaughtExceptionHandler} instead of thread groups.
 *
 * @param t the Thread that terminated with an uncaught exception
 * @param e the uncaught exception itself
 */
public void uncaughtException(Thread t, Throwable e) {
  if (parent != null) {
    parent.uncaughtException(t, e);
  } else if (Thread.getDefaultUncaughtExceptionHandler() != null) {
    // TODO The spec is unclear regarding this. What do we do?
    Thread.getDefaultUncaughtExceptionHandler().uncaughtException(t, e);
  } else if (!(e instanceof ThreadDeath)) {
    // No parent group, has to be 'system' Thread Group
    e.printStackTrace(System.err);
  }
}
origin: robovm/robovm

  private static void finalizerTimedOut(Object object) {
    // The current object has exceeded the finalization deadline; abort!
    String message = object.getClass().getName() + ".finalize() timed out after "
        + (MAX_FINALIZE_NANOS / NANOS_PER_SECOND) + " seconds";
    Exception syntheticException = new TimeoutException(message);
    // We use the stack from where finalize() was running to show where it was stuck.
    syntheticException.setStackTrace(FinalizerDaemon.INSTANCE.getStackTrace());
    Thread.UncaughtExceptionHandler h = Thread.getDefaultUncaughtExceptionHandler();
    if (h == null) {
      // If we have no handler, log and exit.
      System.logE(message, syntheticException);
      System.exit(2);
    }
    // Otherwise call the handler to do crash reporting.
    // We don't just throw because we're not the thread that
    // timed out; we're the thread that detected it.
    h.uncaughtException(Thread.currentThread(), syntheticException);
  }
}
origin: wildfly/wildfly

public void run() {
  Runnable task;
  for (;;) {
    synchronized (this) {
      task = poll();
      if (task == null) {
        runCount--;
        return;
      }
    }
    try {
      task.run();
    } catch (Throwable t) {
      final Thread.UncaughtExceptionHandler handler = LimitedExecutor.this.handler;
      if (handler != null) try {
        handler.uncaughtException(Thread.currentThread(), t);
      } catch (Throwable ignored) {}
    }
  }
}
origin: wildfly/wildfly

void safeRun(final Runnable task) {
  assert ! holdsLock(headLock) && ! holdsLock(tailLock);
  try {
    if (task != null) task.run();
  } catch (Throwable t) {
    try {
      exceptionHandler.uncaughtException(Thread.currentThread(), t);
    } catch (Throwable ignored) {
      // nothing else we can safely do here
    }
  } finally {
    // clear TCCL
    JBossExecutors.clearContextClassLoader(Thread.currentThread());
    // clear interrupt status
    Thread.interrupted();
  }
}
origin: org.springframework.boot/spring-boot

@Override
public void uncaughtException(Thread thread, Throwable ex) {
  try {
    if (isPassedToParent(ex) && this.parent != null) {
      this.parent.uncaughtException(thread, ex);
    }
  }
  finally {
    this.loggedExceptions.clear();
    if (this.exitCode != 0) {
      System.exit(this.exitCode);
    }
  }
}
origin: fusesource/mqtt-client

  public void onFailure(Throwable value) {
    Thread.currentThread().getUncaughtExceptionHandler().uncaughtException(Thread.currentThread(), value);
  }
};
origin: lealone/Lealone

/**
 * Close the file and the storage, without writing anything.
 * This method ignores all errors.
 */
private void closeImmediately() {
  try {
    closeStorage();
  } catch (Exception e) {
    if (backgroundExceptionHandler != null) {
      backgroundExceptionHandler.uncaughtException(null, e);
    }
  }
}
origin: ACRA/acra

/**
 * pass-through to default handler
 *
 * @param t the crashed thread
 * @param e the uncaught exception
 */
public void handReportToDefaultExceptionHandler(@Nullable Thread t, @NonNull Throwable e) {
  if (defaultExceptionHandler != null) {
    ACRA.log.i(LOG_TAG, "ACRA is disabled for " + context.getPackageName()
        + " - forwarding uncaught Exception on to default ExceptionHandler");
    defaultExceptionHandler.uncaughtException(t, e);
  } else {
    ACRA.log.e(LOG_TAG, "ACRA is disabled for " + context.getPackageName() + " - no default ExceptionHandler");
    ACRA.log.e(LOG_TAG, "ACRA caught a " + e.getClass().getSimpleName() + " for " + context.getPackageName(), e);
  }
}
origin: ankidroid/Anki-Android

/**
 * We want to send an analytics hit on any exception, then chain to other handlers (e.g., ACRA)
 */
synchronized private static void installDefaultExceptionHandler() {
  sOriginalUncaughtExceptionHandler = Thread.getDefaultUncaughtExceptionHandler();
  Thread.setDefaultUncaughtExceptionHandler((thread, throwable) -> {
    sendAnalyticsException(throwable, true);
    sOriginalUncaughtExceptionHandler.uncaughtException(thread, throwable);
  });
}
java.langThread$UncaughtExceptionHandler

Javadoc

Interface for handlers invoked when a Thread abruptly terminates due to an uncaught exception.

When a thread is about to terminate due to an uncaught exception the Java Virtual Machine will query the thread for its UncaughtExceptionHandler using #getUncaughtExceptionHandler and will invoke the handler's uncaughtException method, passing the thread and the exception as arguments. If a thread has not had its UncaughtExceptionHandler explicitly set, then its ThreadGroup object acts as its UncaughtExceptionHandler. If the ThreadGroup object has no special requirements for dealing with the exception, it can forward the invocation to the #getDefaultUncaughtExceptionHandler.

Most used methods

  • uncaughtException
    Method invoked when the given thread terminates due to the given uncaught exception.Any exception th

Popular in Java

  • Creating JSON documents from java classes using gson
  • setRequestProperty (URLConnection)
  • getResourceAsStream (ClassLoader)
  • getSupportFragmentManager (FragmentActivity)
  • Graphics2D (java.awt)
    This Graphics2D class extends the Graphics class to provide more sophisticated control overgraphics
  • UnknownHostException (java.net)
    Thrown when a hostname can not be resolved.
  • Date (java.util)
    A specific moment in time, with millisecond precision. Values typically come from System#currentTime
  • SortedMap (java.util)
    A map that has its keys ordered. The sorting is according to either the natural ordering of its keys
  • JFileChooser (javax.swing)
  • Response (javax.ws.rs.core)
    Defines the contract between a returned instance and the runtime when an application needs to provid
  • Top plugins for WebStorm
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now