Package org.jf.util
Class ExceptionWithContext
java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
org.jf.util.ExceptionWithContext
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
AnalysisException,DexFileFactory.DexFileNotFoundException,DexFileFactory.MultipleMatchingDexEntriesException,DexFileFactory.UnsupportedFileTypeException,DexFileFactory.UnsupportedOatVersionException,InstructionOffsetMap.InvalidInstructionIndex,InstructionOffsetMap.InvalidInstructionOffset,MethodDefinition.InvalidSwitchPayload,MethodHandleType.InvalidMethodHandleTypeException,ReferenceType.InvalidReferenceTypeException,TryListBuilder.InvalidTryException,UnresolvedClassException
Exception which carries around structured context.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate StringBuffernon-null; human-oriented context of the exception -
Constructor Summary
ConstructorsConstructorDescriptionExceptionWithContext(String message, Object... formatArgs) Constructs an instance.ExceptionWithContext(Throwable cause) Constructs an instance.ExceptionWithContext(Throwable cause, String message, Object... formatArgs) Constructs an instance. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddContext(String str) Adds a line of context to this instance.private static StringformatMessage(String message, Object... formatArgs) Gets the context.voidprintContext(PrintStream out) Prints the message and context.voidprintContext(PrintWriter out) Prints the message and context.voidvoidstatic ExceptionWithContextwithContext(Throwable ex, String str, Object... formatArgs) 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
-
Field Details
-
context
non-null; human-oriented context of the exception
-
-
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:
cause- null-ok; exception that caused this onemessage- human-oriented message
-
-
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
-
formatMessage
-
printStackTrace
- Overrides:
printStackTracein classThrowable
-
printStackTrace
- Overrides:
printStackTracein 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
-