org.af.commons.errorhandling
Class ErrorHandler

java.lang.Object
  extended by org.af.commons.errorhandling.ErrorHandler

public class ErrorHandler
extends Object

Manager class which handles everything concerning the error handling. You can: - install default exception handlers on the current thread and the EDT - make GUI dialogs for different error types - make a GUI dialog to inform about an error / bug and mail logging info The class is singleton but can be extended by inheritance. For that reason the only creation of an instance is allowed thru the init method an that only once.


Method Summary
 String getDeveloperAddress()
           
static ErrorHandler getInstance()
           
 String getReportURL()
           
static void init(String developerAddress, String reportURL, boolean installDefaultExceptionHandlerOnCurrentThread, boolean installDefaultExceptionHandlerOnEDT)
          Initialize the singleton error handler
static void init(String developerAddress, String reportURL, boolean installDefaultExceptionHandlerOnCurrentThread, boolean installDefaultExceptionHandlerOnEDT, Class clazz)
          Initialize the singleton error handler
 void makeErrDialog(String msg)
          creates a dialog for an error
 void makeErrDialog(String msg, Throwable e)
          creates a dialog for an error
 void makeErrDialog(String msg, Throwable e, boolean fatal)
          creates a dialog for an error
static void setErrorDialogClass(Class clazz)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

init

public static void init(String developerAddress,
                        String reportURL,
                        boolean installDefaultExceptionHandlerOnCurrentThread,
                        boolean installDefaultExceptionHandlerOnEDT,
                        Class clazz)
Initialize the singleton error handler

Parameters:
developerAddress - mail address of the developers, used in inform dialog (don't pass null)
installDefaultExceptionHandlerOnCurrentThread - install DefaultExceptionHandler on the current thread ?
installDefaultExceptionHandlerOnEDT - installs DefaultExceptionHandler on the current thread
clazz - Class of the InformDialog to be called
Throws:
RuntimeException - when developerAddress is null or init was already called before

init

public static void init(String developerAddress,
                        String reportURL,
                        boolean installDefaultExceptionHandlerOnCurrentThread,
                        boolean installDefaultExceptionHandlerOnEDT)
Initialize the singleton error handler

Parameters:
developerAddress - mail address of the developers, used in inform dialog (don't pass null)
installDefaultExceptionHandlerOnCurrentThread - install DefaultExceptionHandler on the current thread ?
installDefaultExceptionHandlerOnEDT - installs DefaultExceptionHandler on the current thread
Throws:
RuntimeException - when developerAddress is null or init was already called before

getInstance

public static ErrorHandler getInstance()
Returns:
the singleton instance
Throws:
RuntimeException - when not initialized before.

getDeveloperAddress

public String getDeveloperAddress()

getReportURL

public String getReportURL()

makeErrDialog

public void makeErrDialog(String msg,
                          Throwable e,
                          boolean fatal)
creates a dialog for an error

Parameters:
msg - error message
e - cause of error
fatal - is the error a fatal error and the application should be shut down

makeErrDialog

public void makeErrDialog(String msg,
                          Throwable e)
creates a dialog for an error

Parameters:
msg - error message
e - cause of error

makeErrDialog

public void makeErrDialog(String msg)
creates a dialog for an error

Parameters:
msg - error message

setErrorDialogClass

public static void setErrorDialogClass(Class clazz)