All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.groupbyinc.common.util.exception.DefaultUncaughtExceptionHandler Maven / Gradle / Ivy

The newest version!
package com.groupbyinc.common.util.exception;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.lang.Thread.UncaughtExceptionHandler;

public class DefaultUncaughtExceptionHandler implements UncaughtExceptionHandler {

  private static final transient Logger LOG = LoggerFactory.getLogger(DefaultUncaughtExceptionHandler.class);

  @Override
  public void uncaughtException(Thread thread, Throwable throwable) {
    LOG.error("Encountered uncaught exception [" + throwable.getClass().getSimpleName() + "] in thread [" + thread.getName() + "]: " + throwable.getMessage(), throwable);
    if (throwable instanceof OutOfMemoryError) {
      System.exit(-1);
    }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy