bb.util
Class UncaughtThrowableLogger

java.lang.Object
  extended by bb.util.UncaughtThrowableLogger
All Implemented Interfaces:
Thread.UncaughtExceptionHandler

public class UncaughtThrowableLogger
extends Object
implements Thread.UncaughtExceptionHandler

Logs all otherwise uncaught Throwables to a Logger.

This class is multithread safe: the types of its state are individually multithread safe, and are used such that only their individual multithread safety matters.

Author:
Brent Boyer
See Also:
Catching Uncaught Exceptions

Nested Class Summary
static class UncaughtThrowableLogger.UnitTest
          See the Overview page of the project's javadocs for a general description of this unit test class.
 
Field Summary
private  Logger logger
          Logger where all Throwables will get logged to.
 
Constructor Summary
UncaughtThrowableLogger()
          Convenience constructor that simply calls this( LogUtil.getLogger2() ).
UncaughtThrowableLogger(Logger logger)
          Fundamental constructor.
 
Method Summary
 void uncaughtException(Thread thread, Throwable throwable)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

private final Logger logger
Logger where all Throwables will get logged to.

Contract: this field is never null.

Constructor Detail

UncaughtThrowableLogger

public UncaughtThrowableLogger()
Convenience constructor that simply calls this( LogUtil.getLogger2() ).


UncaughtThrowableLogger

public UncaughtThrowableLogger(Logger logger)
                        throws IllegalArgumentException
Fundamental constructor. Uses logger to record all otherwise uncaught Throwables.

Throws:
IllegalArgumentException - if logger == null
Method Detail

uncaughtException

public void uncaughtException(Thread thread,
                              Throwable throwable)
Specified by:
uncaughtException in interface Thread.UncaughtExceptionHandler