com.android.dex.util
Class ExceptionWithContext

java.lang.Object
  extended by java.lang.Throwable
      extended by java.lang.Exception
          extended by java.lang.RuntimeException
              extended by com.android.dex.util.ExceptionWithContext
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
DexException

public class ExceptionWithContext
extends RuntimeException

Exception which carries around structured context.

See Also:
Serialized Form

Constructor Summary
ExceptionWithContext(String message)
          Constructs an instance.
ExceptionWithContext(String message, Throwable cause)
          Constructs an instance.
ExceptionWithContext(Throwable cause)
          Constructs an instance.
 
Method Summary
 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)
          
 void printStackTrace(PrintWriter out)
          
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
fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, initCause, printStackTrace, setStackTrace, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ExceptionWithContext

public ExceptionWithContext(String message)
Constructs an instance.

Parameters:
message - human-oriented message

ExceptionWithContext

public ExceptionWithContext(Throwable cause)
Constructs an instance.

Parameters:
cause - null-ok; exception that caused this one

ExceptionWithContext

public ExceptionWithContext(String message,
                            Throwable cause)
Constructs an instance.

Parameters:
message - human-oriented message
cause - null-ok; exception that caused this one
Method Detail

withContext

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 - non-null; the exception to augment
str - non-null; context to add
Returns:
non-null; an appropriate instance

printStackTrace

public void printStackTrace(PrintStream out)

Overrides:
printStackTrace in class Throwable

printStackTrace

public void printStackTrace(PrintWriter out)

Overrides:
printStackTrace in class Throwable

addContext

public void addContext(String str)
Adds a line of context to this instance.

Parameters:
str - non-null; new context

getContext

public String getContext()
Gets the context.

Returns:
non-null; the context

printContext

public void printContext(PrintStream out)
Prints the message and context.

Parameters:
out - non-null; where to print to

printContext

public void printContext(PrintWriter out)
Prints the message and context.

Parameters:
out - non-null; where to print to


Copyright © 2015. All rights reserved.