org.rhq.core.util.exception
Class ExceptionPackage

java.lang.Object
  extended by org.rhq.core.util.exception.ExceptionPackage
All Implemented Interfaces:
Serializable

public class ExceptionPackage
extends Object
implements Serializable

This class can package up an exception in a non-object-serialized form to send to a remote system that might not have the exception class available for deserialization.

Author:
Greg Hinkle, John Mazzitelli
See Also:
WrappedRemotingException, Serialized Form

Constructor Summary
ExceptionPackage(Severity severity, Throwable throwable)
          Creates a new ExceptionPackage object.
ExceptionPackage(Throwable throwable)
          Constructor for ExceptionPackage that assumes the severity is Severity.Warning.
 
Method Summary
 String getAllMessages()
          Returns all the messages for this throwable and all of its causes in one long string.
 ExceptionPackage getCause()
          Returns the cause of this exception in the same non-object-serialized form.
 String getExceptionName()
          Returns the name of the actual exception being packaged.
 String getMessage()
          Returns the message associated with the exception.
 Severity getSeverity()
          Returns the severity of the exception, which marks how important or severe the problem is.
 String getStackTraceString()
          Returns the stack trace for this exception but not of its cause.
 String toString()
          Returns a string consisting of the exception's name, the severity and message of the exception.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ExceptionPackage

public ExceptionPackage(Throwable throwable)
                 throws IllegalArgumentException
Constructor for ExceptionPackage that assumes the severity is Severity.Warning.

Parameters:
throwable -
Throws:
IllegalArgumentException - if throwable is null

ExceptionPackage

public ExceptionPackage(Severity severity,
                        Throwable throwable)
                 throws IllegalArgumentException
Creates a new ExceptionPackage object. If the severity is null, then Severity.Warning is assumed.

Parameters:
severity - the importance of the exception (may be null)
throwable -
Throws:
IllegalArgumentException - if throwable is null
Method Detail

getExceptionName

public String getExceptionName()
Returns the name of the actual exception being packaged. This is equivalent to the getClass().getName() value of the exception.

Returns:
the name of the exception

getSeverity

public Severity getSeverity()
Returns the severity of the exception, which marks how important or severe the problem is.

Returns:
exception severity

getMessage

public String getMessage()
Returns the message associated with the exception.

Returns:
exception message

getCause

public ExceptionPackage getCause()
Returns the cause of this exception in the same non-object-serialized form.

Returns:
exception cause

getStackTraceString

public String getStackTraceString()
Returns the stack trace for this exception but not of its cause.

Returns:
the exception stack trace of this particular exception.

getAllMessages

public String getAllMessages()
Returns all the messages for this throwable and all of its causes in one long string. This is useful for logging an exception when you don't want to dump the entire stack trace but you still want to see the throwable and all of its causes.

Returns:
string containing the throwable's message and its causes' messages in the order of the causes (the lowest nested throwable's message appears last in the string)

toString

public String toString()
Returns a string consisting of the exception's name, the severity and message of the exception.

Overrides:
toString in class Object
See Also:
Object.toString()


Copyright © 2008-2012 Red Hat, Inc.. All Rights Reserved.