Top Description Fields Constructors Methods
org.droidparts.dexmaker.dx.util

public Class ExceptionWithContext

extends RuntimeException
Class Inheritance
Known Direct Subclasses
org.droidparts.dexmaker.dx.util.MutabilityException, org.droidparts.dexmaker.dx.util.DexException
Imports
java.io.PrintStream, .PrintWriter

Exception which carries around structured context.

Field Summary

Modifier and TypeField and Description
private StringBuffer
context

non-null; human-oriented context of the exception

Constructor Summary

AccessConstructor and Description
public
ExceptionWithContext(String
human-oriented message
message
)

Constructs an instance.

public
ExceptionWithContext(Throwable
null-ok; exception that caused this one
cause
)

Constructs an instance.

public
ExceptionWithContext(String
human-oriented message
message
,
Throwable
null-ok; exception that caused this one
cause
)

Constructs an instance.

Method Summary

Modifier and TypeMethod and Description
public void
addContext(String
non-null; new context
str
)

Adds a line of context to this instance.

public String

Returns:

non-null; the context
getContext
()

Gets the context.

public void
printContext(PrintStream
non-null; where to print to
out
)

Prints the message and context.

public void
printContext(PrintWriter
non-null; where to print to
out
)

Prints the message and context.

public void
printStackTrace(PrintStream
PrintStream to use for output
out
)

Overrides java.lang.Throwable.printStackTrace.

Prints this throwable and its backtrace to the specified print stream.
public void
printStackTrace(PrintWriter
PrintWriter to use for output
out
)

Overrides java.lang.Throwable.printStackTrace.

Prints this throwable and its backtrace to the specified print writer.
public static ExceptionWithContext

Returns:

non-null; an appropriate instance
withContext
(Throwable
non-null; the exception to augment
ex
,
String
non-null; context to add
str
)

Augments the given exception with the given context, and return the result.

Field Detail

contextback to summary
private StringBuffer context

non-null; human-oriented context of the exception

Constructor Detail

ExceptionWithContextback to summary
public ExceptionWithContext(String message)

Constructs an instance.

Parameters
message:String

human-oriented message

ExceptionWithContextback to summary
public ExceptionWithContext(Throwable cause)

Constructs an instance.

Parameters
cause:Throwable

null-ok; exception that caused this one

ExceptionWithContextback to summary
public ExceptionWithContext(String message, Throwable cause)

Constructs an instance.

Parameters
message:String

human-oriented message

cause:Throwable

null-ok; exception that caused this one

Method Detail

addContextback to summary
public void addContext(String str)

Adds a line of context to this instance.

Parameters
str:String

non-null; new context

getContextback to summary
public String getContext()

Gets the context.

Returns:String

non-null; the context

printContextback to summary
public void printContext(PrintStream out)

Prints the message and context.

Parameters
out:PrintStream

non-null; where to print to

printContextback to summary
public void printContext(PrintWriter out)

Prints the message and context.

Parameters
out:PrintWriter

non-null; where to print to

printStackTraceback to summary
public void printStackTrace(PrintStream out)

Overrides java.lang.Throwable.printStackTrace.

Doc from java.lang.Throwable.printStackTrace.

Prints this throwable and its backtrace to the specified print stream.

Parameters
out:PrintStream

PrintStream to use for output

Annotations
@Override
printStackTraceback to summary
public void printStackTrace(PrintWriter out)

Overrides java.lang.Throwable.printStackTrace.

Doc from java.lang.Throwable.printStackTrace.

Prints this throwable and its backtrace to the specified print writer.

Parameters
out:PrintWriter

PrintWriter to use for output

Annotations
@Override
withContextback to summary
public static ExceptionWithContext withContext(Throwable ex, String str)

Augments the given exception with the given context, and return the result. The result is either the given exception if it was an ExceptionWithContext, or a newly-constructed exception if it was not.

Parameters
ex:Throwable

non-null; the exception to augment

str:String

non-null; context to add

Returns:ExceptionWithContext

non-null; an appropriate instance