Package com.android.dex.util
Class ExceptionWithContext
java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
com.android.dex.util.ExceptionWithContext
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
DexException
,MutabilityException
,ParseException
,SimException
Exception which carries around structured context.
- See Also:
-
Constructor Summary
ConstructorDescriptionExceptionWithContext
(String message) Constructs an instance.ExceptionWithContext
(String message, Throwable cause) Constructs an instance.ExceptionWithContext
(Throwable cause) Constructs an instance. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addContext
(String str) Adds a line of context to this instance.Gets the context.void
printContext
(PrintStream out) Prints the message and context.void
printContext
(PrintWriter out) Prints the message and context.void
void
static ExceptionWithContext
withContext
(Throwable ex, String str) Augments the given exception with the given context, and return the result.Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, setStackTrace, toString
-
Constructor Details
-
ExceptionWithContext
Constructs an instance.- Parameters:
message
- human-oriented message
-
ExceptionWithContext
Constructs an instance.- Parameters:
cause
-null-ok;
exception that caused this one
-
ExceptionWithContext
Constructs an instance.- Parameters:
message
- human-oriented messagecause
-null-ok;
exception that caused this one
-
-
Method Details
-
withContext
Augments the given exception with the given context, and return the result. The result is either the given exception if it was anExceptionWithContext
, or a newly-constructed exception if it was not.- Parameters:
ex
-non-null;
the exception to augmentstr
-non-null;
context to add- Returns:
non-null;
an appropriate instance
-
printStackTrace
- Overrides:
printStackTrace
in classThrowable
-
printStackTrace
- Overrides:
printStackTrace
in classThrowable
-
addContext
Adds a line of context to this instance.- Parameters:
str
-non-null;
new context
-
getContext
Gets the context.- Returns:
non-null;
the context
-
printContext
Prints the message and context.- Parameters:
out
-non-null;
where to print to
-
printContext
Prints the message and context.- Parameters:
out
-non-null;
where to print to
-