Package jmri.util.swing
Class ExceptionContext
java.lang.Object
jmri.util.swing.ExceptionContext
- Direct Known Subclasses:
UnexpectedExceptionContext
Wraps an Exception and allows extra contextual information to be added, such
as what was happening at the time of the Exception, and a hint as to what the
user might do to correct the problem. Also implements a number of methods to
format the data of an Exception.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionExceptionContext(Throwable ex, String operation, String hint) Create a new Exception Context. -
Method Summary
Modifier and TypeMethodDescriptiongetClipboardString(boolean includeSysInfo) Get a String form of this Context for use in pasting to Clipboard.Get the Exception being wrapped.getHint()Get suggestion to the user to correct the problem.Get what was happening when the exception occurred.Used to give a more friendly message.getStackTraceAsString(int maxLevels) Returns up to the given number of stack trace elements concatenated into one string.Get the Full Stack Trace String.Returns a user friendly summary of the Exception.getTitle()Get a String to use as the Title for this Context.
-
Field Details
-
exception
-
prefaceString
-
operation
-
hint
-
-
Constructor Details
-
ExceptionContext
Create a new Exception Context.- Parameters:
ex- the Throwable Exception which has occurred.operation- An Operation which was taking place at the time of the Exception. Use empty String if unknown.hint- A hint as to what might have caused the Exception. Use empty String if unknown.
-
-
Method Details
-
getException
Get the Exception being wrapped.- Returns:
- the Exception.
-
getPreface
Used to give a more friendly message.- Returns:
- the Preface String.
-
getOperation
Get what was happening when the exception occurred.- Returns:
- empty String if unknown.
-
getHint
Get suggestion to the user to correct the problem.- Returns:
- empty string if no hint, else the hint text.
-
getTitle
Get a String to use as the Title for this Context.- Returns:
- Localised Exception message, truncated to 80 chars.
-
getSummary
Returns a user friendly summary of the Exception. Empty data is excluded.- Returns:
- A string summary.
-
getStackTraceAsString
Returns up to the given number of stack trace elements concatenated into one string.- Parameters:
maxLevels- The number of stack trace elements to return.- Returns:
- A string stack trace.
-
getStackTraceString
Get the Full Stack Trace String.- Returns:
- unabridged Stack Trace String.
-
getClipboardString
Get a String form of this Context for use in pasting to Clipboard.- Parameters:
includeSysInfo- true to include System Information, false for just the Exception details.- Returns:
- String for use in Clipboard text.
-