|
Oracle Fusion Middleware Java API Reference for Oracle Extension SDK Reference 11g Release 1 (11.1.1.7.2) E13403-10 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object
oracle.javatools.dialogs.ExceptionDialog
public class ExceptionDialog
Dialog to display an exception and optional message to the user. The dialog includes a Details button which can display a stack trace, or a list of stack traces (for "chained" exceptions such as SQLException
).
In general, when runtime exceptions occur in the IDE or in extensions, this dialog should be used in preference to printing the stack trace to the console or using Assert.printStackTrace(). It's important for diagnostic purposes that users have information they can provide to support to help pinpoint problems. In addition, the use of this dialog helps extension developers to identify problems while developing extension code.
Whenever event handling code is written that may cause a RuntimeException to be thrown on the AWT event thread, it should be surrounded by a try/catch block like the following:
public void actionPerformed(ActionEvent ae) { try { doSomething(); } catch (RuntimeException re) { // Use the "messageless" version, which reports as an "internal // error" ExceptionDialog.showExceptionDialog( parent, re ); } }
Important: do not invoke the exception dialog in code that is called from paint(), including Swing component renderers. Doing so may result in the user being unable to dismiss the dialog. In addition, certain components have listeners which are notified in a way that is not compatible with using this dialog. For instance, list, tree or table selection events may be fired several times.
By default, the exception dialog has message text and an associated help topic that indicate that the error was an internal or unexpected error. For consistency, this should be the default error message for runtime exceptions that are not otherwise handled.
In addition to reporting "internal errors", the exception dialog can be used as a general error reporting mechanism where the stack trace may be of interest to the user. It should be used sparingly for this purpose. Often the stack trace is irrelevant and should not be displayed. Using the exception dialog in such circumstances can lead to a "fear factor"; the user is used to this particular dialog being used for internal errors and may misinterpret the severity of your error message. In most cases, consider using the MessageDialog to display a plain alert.
The exception dialog has built in support for chained SQLExceptions. You can also provide an implementation of ThrowableChainTraverser and call the registerThrowableChainTraverser() to handle other types of chained exception.
Note: This dialog handles ThreadDeath
specially. ThreadDeath exceptions are never reported; the showExceptionDialog() methods will immediately throw the exception back out if it is an instance of ThreadDeath.
MessageDialog
, Frame
, Exception
, SQLException
Nested Class Summary | |
---|---|
static interface |
ExceptionDialog.ThrowableChainTraverser An interface describing how to traverse a chain of exceptions |
Method Summary | |
---|---|
protected java.util.List |
getThrowableChain(java.lang.Throwable t) |
protected boolean |
isChainedThrowable(java.lang.Throwable t) Return true if the specified throwable is chaied. |
static void |
registerThrowableChainTraverser(java.lang.Class exceptionClass, ExceptionDialog.ThrowableChainTraverser tct) Register a ThrowableChainTraverser with the ExceptionDialog utility. |
static void |
showExceptionDialog(java.awt.Component parent, java.lang.Throwable t) Show an exception dialog based on a component and a throwable. |
static void |
showExceptionDialog(java.awt.Component parent, java.lang.Throwable t, java.lang.String message) Show an exception dialog with a message |
static void |
showExceptionDialog(java.awt.Component parent, java.lang.Throwable t, java.lang.String title, java.lang.String message, java.lang.String helpTopicID) Preferred method for invoking the exception dialog. |
static int |
showExceptionDialog(java.awt.Window parent, java.lang.Exception ex) Displays an Exception dialog to the user. |
static int |
showExceptionDialog(java.awt.Window parent, java.lang.Exception ex, java.lang.String message) Displays an exception dialog to the user. |
static int |
showExceptionDialog(java.awt.Window parent, java.lang.Exception ex, java.lang.String title, java.lang.String message) Displays an Exception dialog to the user. |
static void |
unregisterThrowableChainTraverser(ExceptionDialog.ThrowableChainTraverser tct) Unregister ThrowableChainTraverser |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static void showExceptionDialog(java.awt.Component parent, java.lang.Throwable t)
parent
- the parent component of the dialogt
- an exception to reportpublic static void showExceptionDialog(java.awt.Component parent, java.lang.Throwable t, java.lang.String message)
parent
- the parent component of the dialogt
- an exception to reportpublic static void showExceptionDialog(java.awt.Component parent, java.lang.Throwable t, java.lang.String title, java.lang.String message, java.lang.String helpTopicID)
component
- component that this dialog will be parented upont
- Throwable to display in dialogtitle
- title bar caption for the dialogmessage
- Text message to display to the user in addition to the exception text.helpTopicID
- a help topic ID to attach to the help button of the exception dialog.public static int showExceptionDialog(java.awt.Window parent, java.lang.Exception ex, java.lang.String title, java.lang.String message)
parent
- Frame that this dialog will be parented uponex
- Exception to display in dialogtitle
- title bar caption for the dialogmessage
- Text message to display to the user in addition to the exception text.public static int showExceptionDialog(java.awt.Window parent, java.lang.Exception ex, java.lang.String message)
parent
- Frame that this dialog will be parented uponex
- Exception to display in dialogmessage
- Text message to display to the user in addition to the exception text.public static int showExceptionDialog(java.awt.Window parent, java.lang.Exception ex)
parent
- Frame/Dialog that this dialog will be parented uponex
- Exception to display in dialogpublic static void registerThrowableChainTraverser(java.lang.Class exceptionClass, ExceptionDialog.ThrowableChainTraverser tct)
public static void unregisterThrowableChainTraverser(ExceptionDialog.ThrowableChainTraverser tct)
protected boolean isChainedThrowable(java.lang.Throwable t)
protected java.util.List getThrowableChain(java.lang.Throwable t)
|
Oracle Fusion Middleware Java API Reference for Oracle Extension SDK Reference 11g Release 1 (11.1.1.7.2) E13403-10 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |