WrappedThrowable Class
- public class WrappedThrowable
extends Object
implements Serializable
Wraps an exception that was thrown on the server so that information about the exception
can be obtained by any client without having to worry about whether the original exception
is in the classpath of the caller. This is required if an exception thrown on the server is not necessarily
on clients classpath. Such Throwables are wrapped by serializing them into a byte array so that
they can be selectively deserialized on the client. If the deserialization of the original exception fails
the client can ask for a simpler representation of the original exception that is guaranteed to be
on clients classpath. This simple representation has stack trace and exception message of the original throwable
-
Hierarchy
-
Object
WrappedThrowable
-
All Implemented Interfaces
-
Serializable
Methods from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
WrappedThrowable
public WrappedThrowable(Throwable
wrappedThrowable,
int maxDataSize)
- Constructor for wrapping a throwable.
getOriginalForm() Method
public Throwable
getOriginalForm()
throws IOException
, ClassNotFoundException
Returns the original (wrapped) throwable. This method should be called only if the
class of the wrapped throwable is known to be in the classpath of the caller. The caller
should typically call WrappedThrowable.getSimpleForm()
to get the alternative simpler representation
of this class if the original form could not be obtained due to an exception
Returns
- the original wrapped throwable. Returns
null
if the original Throwable
could not be serialized due to some serialization error.
Exceptions
-
IOException
-
ClassNotFoundException
getOriginalThrowableClassName() Method
public String
getOriginalThrowableClassName()
Returns the class name of the wrapped Throwable. This method can be used to
verify if the original throwable is in the classpath of the caller, before
calling WrappedThrowable.getOriginalForm()
getSimpleForm() Method
public Throwable
getSimpleForm()
Returns a simple representation of the original throwable. This method should be used
if the call to WrappedThrowable.getOriginalForm()
has failed because the class of the original Throwable was
not on callers classpath.
Returns
- a simple representation of the original throwable.
getThrowable() Method
public Throwable
getThrowable()
Returns the original exception if it can be deserialized without errors and if it is not null.
Otherwise returns the simple form.