- java.lang.Object
-
- java.lang.Throwable
-
- java.lang.Error
-
- com.aoapps.lang.exception.WrappedError
-
- All Implemented Interfaces:
ExtraInfo,Serializable
public class WrappedError extends Error implements ExtraInfo
A wrapped error may be used to rethrow any throwable in a context where
Erroris expected. As this is not often the case, you probably want to useWrappedExceptionto wrap checked exceptions.This could be accomplished by rethrowing with
Errordirectly, but having this distinct class provides more meaning as well as the ability to catch wrapped errors while letting all other errors go through directly.Catching
WrappedErrormay be used to unwrap expected throwable types.- Author:
- AO Industries, Inc.
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description WrappedError(String message, Throwable cause)Uses extra info of the original cause when it is anExtraInfo.WrappedError(String message, Throwable cause, Object... extraInfo)WrappedError(Throwable cause)Uses extra info of the original cause when it is anExtraInfo.WrappedError(Throwable cause, Object... extraInfo)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Object[]getExtraInfo()Gets the optional extra info associated with an exception.StringgetLocalizedMessage()StringgetMessage()-
Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
-
-
-
-
Constructor Detail
-
WrappedError
public WrappedError(Throwable cause)
Uses extra info of the original cause when it is anExtraInfo.
-
WrappedError
public WrappedError(Throwable cause, Object... extraInfo)
- Parameters:
extraInfo- No defensive copy
-
WrappedError
public WrappedError(String message, Throwable cause)
Uses extra info of the original cause when it is anExtraInfo.
-
-
Method Detail
-
getMessage
public String getMessage()
- Overrides:
getMessagein classThrowable
-
getLocalizedMessage
public String getLocalizedMessage()
- Overrides:
getLocalizedMessagein classThrowable
-
getExtraInfo
public Object[] getExtraInfo()
Gets the optional extra info associated with an exception.- Specified by:
getExtraInfoin interfaceExtraInfo- Returns:
- No defensive copy
-
-