|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.lang.Throwable
java.lang.Exception
org.bushe.swing.exception.SwingException
public class SwingException
Aids in troubleshooting Swing application exceptions or any exception where the caller's stack may not be the exception stack (such as producer-consumer patterns that cross threads).
Swing exceptions usually occur on the Swing Event Dispatch Thread, and often occur when code puts events on the EDT. This code is often in a non-EDT thread such as a thread that is receiving data from a server. If the non-EDT threads puts a call on the EDT and that EDT call causes and exception, the stack trace of the exception is lost, and it often difficult or impossible to determine where the non-EDT call came from. This Exception class is used to handle exceptions that occur when events are posted on the Swing EDT or occur on another thread from the Swing EDT. It includes a "swing" call stack to record from where the event occurred, and overrides so that the exception and the swing calling stack print nicely to logs. The swing calling stack is different from the cause of the exception since it is gathered before the exception occurs in a different stack from the cause and used after the exception in a new thread occurs.
Field Summary | |
---|---|
protected StackTraceElement[] |
callingStackTrace
|
Constructor Summary | |
---|---|
SwingException()
Default constructor |
|
SwingException(String message)
Constructor for compatibility with Exception. |
|
SwingException(String message,
Throwable cause)
Constructor for compatibility with Exception Use ClientException(String, Throwable, StackTraceElement[]) instead |
|
SwingException(String message,
Throwable cause,
StackTraceElement[] callingStack)
Preferred constructor. |
|
SwingException(Throwable cause)
Constructor for compatibility with Exception Use ClientException(String, Throwable, StackTraceElement[]) instead |
Method Summary | |
---|---|
StackTraceElement[] |
getCallingStack()
Client exceptions often have two stacks - one thread causes the posting of an action on another thread - usually the Swing EDT thread. |
void |
printStackTrace(PrintStream ps)
Calls printWriter(ps, true) |
void |
printStackTrace(PrintWriter pw)
Prints the calling stack and the exception stack trace. |
void |
setCallingStack(StackTraceElement[] swingCallingStack)
Swing exceptions often have two stacks - one thread causes the posting of an action on another thread - usually the Swing EDT thread. |
Methods inherited from class java.lang.Throwable |
---|
fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, initCause, printStackTrace, setStackTrace, toString |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected StackTraceElement[] callingStackTrace
Constructor Detail |
---|
public SwingException()
public SwingException(String message)
public SwingException(Throwable cause)
public SwingException(String message, Throwable cause)
public SwingException(String message, Throwable cause, StackTraceElement[] callingStack)
message
- The message of exceptioncause
- The cause of the exception in the same call stackcallingStack
- the stack trace that the client used to call the exception to occur.Method Detail |
---|
public void setCallingStack(StackTraceElement[] swingCallingStack)
swingCallingStack
- the stack trace that the client used to cause the exception to occur.public StackTraceElement[] getCallingStack()
public void printStackTrace(PrintStream ps)
printStackTrace
in class Throwable
ps
- the print streampublic void printStackTrace(PrintWriter pw)
printStackTrace
in class Throwable
pw
-
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |