Class PortableException
- java.lang.Object
-
- java.lang.Throwable
-
- java.lang.Exception
-
- com.saperion.common.lang.exception.PortableException
-
- All Implemented Interfaces:
java.io.Serializable
public final class PortableException extends java.lang.Exception
An
Exception
-implementation that substitutes otherThrowable
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 toconvert(Throwable)
. This method will convert the whole error-stack toPortableException
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 ofBaseException
may be excluded this way.- Author:
- agz
- See Also:
- Serialized Form
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static java.lang.Exception
convert(java.lang.Throwable throwable)
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(java.lang.Class<? extends BaseException> clazz)
Excludes the specifiedBaseException
-Class
and all its subclasses from future conversions.java.lang.String
toString()
-
-
-
Method Detail
-
excludePortableBaseExceptionFromConversion
public static void excludePortableBaseExceptionFromConversion(java.lang.Class<? extends BaseException> clazz)
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
public static java.lang.Exception convert(java.lang.Throwable throwable)
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
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Throwable
-
-