org.elkoserver.util.trace
Class ExceptionManager

java.lang.Object
  extended by org.elkoserver.util.trace.ExceptionManager

public class ExceptionManager
extends Object

A collection of static methods for doing useful things with exceptions.


Method Summary
static RuntimeException asSafe(Throwable problem)
          Wrap a Throwable in a RuntimeException.
static void printStackTrace(Throwable problem)
          Prints a Throwable and its backtrace to the standard error stream in way that knows about non-local exceptions.
static void printStackTrace(Throwable problem, PrintStream out)
          Prints a Throwable and its backtrace to the specified print stream in way that knows about non-local exceptions.
static void printStackTrace(Throwable problem, PrintStream out, boolean nonLocal)
          Prints a Throwable and its backtrace to the specified print stream in way that knows about non-local exceptions.
static void reportException(Throwable problem)
          Handle an exception, either by printing its stack trace to the standard error stream or, if an ExceptionNoticer has been registered, by informing the ExceptionNoticer.
static void reportException(Throwable problem, boolean nonLocal)
          Handle an exception, either by printing its stack trace to the standard error stream or, if an ExceptionNoticer has been registered, by informing the ExceptionNoticer.
static void reportException(Throwable problem, String msg)
          Handle an exception, either by printing its stack trace to the standard error stream or, if an ExceptionNoticer has been registered, by informing the ExceptionNoticer.
static void reportException(Throwable problem, String msg, boolean nonLocal)
          Handle an exception, either by printing its stack trace to the standard error stream or, if an ExceptionNoticer has been registered, by informing the ExceptionNoticer.
static void setExceptionNoticer(ExceptionNoticer noticer)
          Register an ExceptionNoticer to be informed whenever one of the reportException() methods is called.
static void uncaughtException(Thread thread, Throwable problem)
          Report an uncaught exception.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

asSafe

public static RuntimeException asSafe(Throwable problem)
Wrap a Throwable in a RuntimeException.

Wraps problem if necessary so that the caller can do a

     throw ExceptionMgr.asSafe(problem); 
without having to declare any new "throws" cases. The caller does the throw rather than this method so that the Java compiler will have better control flow information.

Parameters:
problem - The Throwable to wrap

printStackTrace

public static void printStackTrace(Throwable problem)
Prints a Throwable and its backtrace to the standard error stream in way that knows about non-local exceptions.

Parameters:
problem - The Throwable to print a stack trace for.

printStackTrace

public static void printStackTrace(Throwable problem,
                                   PrintStream out)
Prints a Throwable and its backtrace to the specified print stream in way that knows about non-local exceptions.

Parameters:
problem - The Throwable to print a stack trace for.
out - Print stream to print it on.

printStackTrace

public static void printStackTrace(Throwable problem,
                                   PrintStream out,
                                   boolean nonLocal)
Prints a Throwable and its backtrace to the specified print stream in way that knows about non-local exceptions.

Parameters:
problem - The Throwable to print a stack trace for.
out - Print stream to print it on
nonLocal - If true, also report the site from which the stack trace is being printed.

reportException

public static void reportException(Throwable problem)
Handle an exception, either by printing its stack trace to the standard error stream or, if an ExceptionNoticer has been registered, by informing the ExceptionNoticer. The exception is considered local.

Parameters:
problem - The Throwable to report.

reportException

public static void reportException(Throwable problem,
                                   String msg)
Handle an exception, either by printing its stack trace to the standard error stream or, if an ExceptionNoticer has been registered, by informing the ExceptionNoticer. The exception is considered local.

Parameters:
problem - The Throwable to report.
msg - Error message to accompany the report.

reportException

public static void reportException(Throwable problem,
                                   String msg,
                                   boolean nonLocal)
Handle an exception, either by printing its stack trace to the standard error stream or, if an ExceptionNoticer has been registered, by informing the ExceptionNoticer.

Parameters:
problem - The Throwable to report.
msg - Error message to accompany the report.
nonLocal - If true, also report the site from which the stack trace is being printed.

reportException

public static void reportException(Throwable problem,
                                   boolean nonLocal)
Handle an exception, either by printing its stack trace to the standard error stream or, if an ExceptionNoticer has been registered, by informing the ExceptionNoticer.

Parameters:
problem - The Throwable to report.
nonLocal - If true, also report the site from which the stack trace is being printed.

setExceptionNoticer

public static void setExceptionNoticer(ExceptionNoticer noticer)
Register an ExceptionNoticer to be informed whenever one of the reportException() methods is called.

Parameters:
noticer - The noticer to call.

uncaughtException

public static void uncaughtException(Thread thread,
                                     Throwable problem)
Report an uncaught exception.

Parameters:
thread - The thread this happened in.
problem - The exception that wasn't caught.