public class ExceptionWithContext extends RuntimeException
| Constructor and Description |
|---|
ExceptionWithContext(String message)
Constructs an instance.
|
ExceptionWithContext(String message,
Throwable cause)
Constructs an instance.
|
ExceptionWithContext(Throwable cause)
Constructs an instance.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addContext(String str)
Adds a line of context to this instance.
|
String |
getContext()
Gets the context.
|
void |
printContext(PrintStream out)
Prints the message and context.
|
void |
printContext(PrintWriter out)
Prints the message and context.
|
void |
printStackTrace(PrintStream out)
Writes a printable representation of this
Throwable's stack trace
to the given print stream. |
void |
printStackTrace(PrintWriter out)
Writes a printable representation of this
Throwable's stack trace
to the specified print writer. |
static ExceptionWithContext |
withContext(Throwable ex,
String str)
Augments the given exception with the given context, and return the
result.
|
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, setStackTrace, toStringpublic ExceptionWithContext(String message)
message - human-oriented messagepublic ExceptionWithContext(Throwable cause)
cause - null-ok; exception that caused this onepublic static ExceptionWithContext withContext(Throwable ex, String str)
ExceptionWithContext, or a newly-constructed exception if it
was not.ex - non-null; the exception to augmentstr - non-null; context to addnon-null; an appropriate instancepublic void printStackTrace(PrintStream out)
Throwable's stack trace
to the given print stream. If the Throwable contains a
cause, the method will be invoked recursively for
the nested Throwable.printStackTrace in class Throwablepublic void printStackTrace(PrintWriter out)
Throwable's stack trace
to the specified print writer. If the Throwable contains a
cause, the method will be invoked recursively for the
nested Throwable.printStackTrace in class Throwableout - the writer to write the stack trace on.public void addContext(String str)
str - non-null; new contextpublic String getContext()
non-null; the contextpublic void printContext(PrintStream out)
out - non-null; where to print topublic void printContext(PrintWriter out)
out - non-null; where to print to