Class PortableException
- All Implemented Interfaces:
Serializable
An Exception-implementation that substitutes other Throwables in an error-stack to make their
information portable to other JVMs.
In a client-server system, ClassNotFoundExceptions 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 PortableExceptions by
a call to convert(Throwable). This method will convert the whole error-stack to
PortableExceptions 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 ExceptionConverts the specifiedThrowableand all its cause-throwables recursive toPortableExceptions if their class (or one of its super classes) was not excluded from conversion by a previous call toexcludePortableBaseExceptionFromConversion(Class).static voidexcludePortableBaseExceptionFromConversion(Class<? extends BaseException> clazz) Excludes the specifiedBaseException-Classand 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-Classand 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-Classto exclude from conversion
-
convert
Converts the specifiedThrowableand all its cause-throwables recursive toPortableExceptions 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
-