edu.rice.cs.drjava.ui
Class DrJavaErrorHandler

java.lang.Object
  extended by edu.rice.cs.drjava.ui.DrJavaErrorHandler
All Implemented Interfaces:
Thread.UncaughtExceptionHandler

public class DrJavaErrorHandler
extends Object
implements Thread.UncaughtExceptionHandler

The handle() method in this class is called every time an uncaught exception propagates to an AWT action. The static log() method can be used to put log entries into the error log but continue execution. This does not automatically update the "DrJava Errors" window when new errors occur. In the case of errors, we want to minimize the effects on the GUI. If we want to see an updated dialog, we can click on the "DrJava Errors" button again.

Version:
$Id: DrJavaErrorHandler.java 5439 2011-08-11 17:13:04Z rcartwright $

Nested Class Summary
static class DrJavaErrorHandler.LoggedCondition
          The throwable used for logging unexpected situations.
 
Field Summary
private static ArrayList<Throwable> _errors
          the list of errors
private static JButton _errorsButton
          the button to show
static DrJavaErrorHandler INSTANCE
           
 
Constructor Summary
private DrJavaErrorHandler()
           
 
Method Summary
static void clearErrors()
          Clears the list of errors.
static JButton getButton()
          Gets the button to show.
static Throwable getError(int index)
          Returns the error with the given index.
static int getErrorCount()
          Returns the size of the error list.
static boolean isSwingBugArrayIndexOufOfBoundsExceptionInCharWidth(Throwable thrown)
          Return true if this is an exception thrown because of the Swing bug: https://sourceforge.net/tracker/?func=detail&atid=438935&aid=2831821&group_id=44253
static void log(String message)
          Log an unexpected situation.
static void record(Throwable thrown)
          Record the throwable in the errors list.
static void setButton(JButton b)
          Sets the button to show.
static void simulateSwingBugArrayIndexOufOfBoundsExceptionInCharWidth()
          Simulate the Swing bug's exception stack trace.
 void uncaughtException(Thread t, Throwable thrown)
          Handles an uncaught exception.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INSTANCE

public static final DrJavaErrorHandler INSTANCE

_errors

private static volatile ArrayList<Throwable> _errors
the list of errors


_errorsButton

private static volatile JButton _errorsButton
the button to show

Constructor Detail

DrJavaErrorHandler

private DrJavaErrorHandler()
Method Detail

uncaughtException

public void uncaughtException(Thread t,
                              Throwable thrown)
Handles an uncaught exception. This gets called automatically by AWT.

Specified by:
uncaughtException in interface Thread.UncaughtExceptionHandler

setButton

public static void setButton(JButton b)
Sets the button to show.


getButton

public static JButton getButton()
Gets the button to show.


getErrorCount

public static int getErrorCount()
Returns the size of the error list.


getError

public static Throwable getError(int index)
Returns the error with the given index.


clearErrors

public static void clearErrors()
Clears the list of errors.


record

public static void record(Throwable thrown)
Record the throwable in the errors list.


isSwingBugArrayIndexOufOfBoundsExceptionInCharWidth

public static boolean isSwingBugArrayIndexOufOfBoundsExceptionInCharWidth(Throwable thrown)
Return true if this is an exception thrown because of the Swing bug: https://sourceforge.net/tracker/?func=detail&atid=438935&aid=2831821&group_id=44253

Returns:
true if this is the Swing bug

simulateSwingBugArrayIndexOufOfBoundsExceptionInCharWidth

public static void simulateSwingBugArrayIndexOufOfBoundsExceptionInCharWidth()
Simulate the Swing bug's exception stack trace.


log

public static void log(String message)
Log an unexpected situation.