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.ExceptionAn
Exception-implementation that substitutes otherThrowables 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 toconvert(Throwable). This method will convert the whole error-stack toPortableExceptions 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 ofBaseExceptionmay 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.Exceptionconvert(java.lang.Throwable throwable)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).static voidexcludePortableBaseExceptionFromConversion(java.lang.Class<? extends BaseException> clazz)Excludes the specifiedBaseException-Classand all its subclasses from future conversions.java.lang.StringtoString()
-
-
-
Method Detail
-
excludePortableBaseExceptionFromConversion
public static void excludePortableBaseExceptionFromConversion(java.lang.Class<? extends BaseException> clazz)
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
public static java.lang.Exception convert(java.lang.Throwable throwable)
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
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Throwable
-
-