Class PortableException
- All Implemented Interfaces:
Serializable
An Exception
-implementation that substitutes other Throwable
s in an error-stack to make their
information portable to other JVMs.
In a client-server system, ClassNotFoundException
s may occur, if the server throws a throwable and tries to
send it to the client, because the class of the throwable or any of its cause-throwables is not available on the
client.
To solve this problem, one may convert the throwable (and all its cause-throwables) to PortableException
s by
a call to convert(Throwable)
. This method will convert the whole error-stack to
PortableException
s that contain the same semantics, i.e. the message-, cause- and stacktrace-informations are
the same.
The server can exclude classes that need not be converted with a call to
excludePortableBaseExceptionFromConversion(Class)
. This is a global setting and should be
done before any exception is to be converted (usually during server startup). Only subclasses of
BaseException
may be excluded this way.
- Author:
- agz
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic Exception
Converts the specifiedThrowable
and all its cause-throwables recursive toPortableException
s if their class (or one of its super classes) was not excluded from conversion by a previous call toexcludePortableBaseExceptionFromConversion(Class)
.static void
excludePortableBaseExceptionFromConversion
(Class<? extends BaseException> clazz) Excludes the specifiedBaseException
-Class
and all its subclasses from future conversions.toString()
Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace
-
Method Details
-
excludePortableBaseExceptionFromConversion
Excludes the specifiedBaseException
-Class
and all its subclasses from future conversions. Once set this setting can not be revoked. Several calls to this method are additive. The specified class must not benull
.- Parameters:
clazz
-BaseException
-Class
to exclude from conversion
-
convert
Converts the specifiedThrowable
and all its cause-throwables recursive toPortableException
s if their class (or one of its super classes) was not excluded from conversion by a previous call toexcludePortableBaseExceptionFromConversion(Class)
. If the specified throwable isnull
, the method returnsnull
.- Parameters:
throwable
- throwable to convert- Returns:
- converted throwable (may be the same as specified)
-
toString
-