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:
java.io.Serializable
- Direct Known Subclasses:
AnalysisException
,DexFileFactory.DexFileNotFoundException
,DexFileFactory.MultipleMatchingDexEntriesException
,DexFileFactory.UnsupportedFileTypeException
,DexFileFactory.UnsupportedOatVersionException
,InstructionOffsetMap.InvalidInstructionIndex
,InstructionOffsetMap.InvalidInstructionOffset
,MethodHandleType.InvalidMethodHandleTypeException
,ReferenceType.InvalidReferenceTypeException
,TryListBuilder.InvalidTryException
,UnresolvedClassException
public class ExceptionWithContext extends java.lang.RuntimeException
Exception which carries around structured context.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description ExceptionWithContext(java.lang.String message, java.lang.Object... formatArgs)
Constructs an instance.ExceptionWithContext(java.lang.Throwable cause)
Constructs an instance.ExceptionWithContext(java.lang.Throwable cause, java.lang.String message, java.lang.Object... formatArgs)
Constructs an instance.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addContext(java.lang.String str)
Adds a line of context to this instance.java.lang.String
getContext()
Gets the context.void
printContext(java.io.PrintStream out)
Prints the message and context.void
printContext(java.io.PrintWriter out)
Prints the message and context.void
printStackTrace(java.io.PrintStream out)
void
printStackTrace(java.io.PrintWriter out)
static ExceptionWithContext
withContext(java.lang.Throwable ex, java.lang.String str, java.lang.Object... formatArgs)
Augments the given exception with the given context, and return the result.
-
-
-
Constructor Detail
-
ExceptionWithContext
public ExceptionWithContext(java.lang.String message, java.lang.Object... formatArgs)
Constructs an instance.- Parameters:
message
- human-oriented message
-
ExceptionWithContext
public ExceptionWithContext(java.lang.Throwable cause)
Constructs an instance.- Parameters:
cause
- null-ok; exception that caused this one
-
ExceptionWithContext
public ExceptionWithContext(java.lang.Throwable cause, java.lang.String message, java.lang.Object... formatArgs)
Constructs an instance.- Parameters:
message
- human-oriented messagecause
- null-ok; exception that caused this one
-
-
Method Detail
-
withContext
public static ExceptionWithContext withContext(java.lang.Throwable ex, java.lang.String str, java.lang.Object... formatArgs)
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
public void printStackTrace(java.io.PrintStream out)
- Overrides:
printStackTrace
in classjava.lang.Throwable
-
printStackTrace
public void printStackTrace(java.io.PrintWriter out)
- Overrides:
printStackTrace
in classjava.lang.Throwable
-
addContext
public void addContext(java.lang.String str)
Adds a line of context to this instance.- Parameters:
str
- non-null; new context
-
getContext
public java.lang.String getContext()
Gets the context.- Returns:
- non-null; the context
-
printContext
public void printContext(java.io.PrintStream out)
Prints the message and context.- Parameters:
out
- non-null; where to print to
-
printContext
public void printContext(java.io.PrintWriter out)
Prints the message and context.- Parameters:
out
- non-null; where to print to
-
-