Package com.google.gwt.core.shared
Class SerializableThrowable
java.lang.Object
java.lang.Throwable
com.google.gwt.core.shared.SerializableThrowable
- All Implemented Interfaces:
Serializable
A serializable copy of a
Throwable
, including its causes and stack trace. It overrides
#toString
to mimic original Throwable.toString()
so that Throwable.printStackTrace()
will work as if it is coming from the original exception.
This class is especially useful for logging and testing as the emulated Throwable class does not serialize recursively and does not serialize the stack trace. This class, as an alternative, can be used to transfer the Throwable without losing any of these data, even if the underlying Throwable is not serializable.
Please note that, to get more useful stack traces from client side, this class needs to be used
in conjunction with StackTraceDeobfuscator
.
NOTE: Does not serialize suppressed exceptions to remain compatible with Java 6 and below.
- See Also:
-
Constructor Summary
ConstructorDescriptionSerializableThrowable
(String designatedType, String message) Constructs a new SerializableThrowable with the specified detail message. -
Method Summary
Modifier and TypeMethodDescriptionstatic SerializableThrowable
fromThrowable
(Throwable throwable) Create a newSerializableThrowable
from a provided throwable and its causes recursively.Returns the designated throwable's type name.Returns the original throwable that this serializable throwable is derived from.Initializes the cause of this throwable.boolean
Returntrue
if provided type name is the exact type of the throwable that is designated by this instance.void
setDesignatedType
(String typeName, boolean isExactType) Sets the designated Throwable's type name.toString()
Methods inherited from class java.lang.Throwable
addSuppressed, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, printStackTrace, printStackTrace, printStackTrace, setStackTrace
-
Constructor Details
-
SerializableThrowable
Constructs a new SerializableThrowable with the specified detail message.
-
-
Method Details
-
fromThrowable
Create a newSerializableThrowable
from a provided throwable and its causes recursively.- Returns:
- a new SerializableThrowable or the passed object itself if it is
null
or already a SerializableThrowable.
-
fillInStackTrace
- Overrides:
fillInStackTrace
in classThrowable
-
setDesignatedType
Sets the designated Throwable's type name.- Parameters:
typeName
- the class name of the underlying designated throwable.isExactType
-false
if provided type name is not the exact type.- See Also:
-
getDesignatedType
Returns the designated throwable's type name.- See Also:
-
isExactDesignatedTypeKnown
public boolean isExactDesignatedTypeKnown()Returntrue
if provided type name is the exact type of the throwable that is designated by this instance. This can returnfalse
if the class metadata is not available in the runtime. In that casegetDesignatedType()
will return the type resolved by best-effort and may not be the exact type; instead it can be one of the ancestors of the real type that this instance designates. -
initCause
Initializes the cause of this throwable.This method will convert the cause to
SerializableThrowable
if it is not already. -
getOriginalThrowable
Returns the original throwable that this serializable throwable is derived from. Note that the original throwable is kept in a transient field; that is; it will not be transferred to server side. In that case this method will returnnull
. -
toString
-