- java.lang.Object
-
- java.lang.Throwable
-
- java.lang.Exception
-
- java.lang.RuntimeException
-
- com.aoapps.lang.exception.WrappedException
-
- All Implemented Interfaces:
ExtraInfo,Serializable
public class WrappedException extends RuntimeException implements ExtraInfo
A wrapped exception may be used to rethrow checked exceptions in a context where they are otherwise not allowed.
This could be accomplished by rethrowing with
RuntimeExceptiondirectly, but having this distinct class provides more meaning as well as the ability to catch wrapped exceptions while letting all other runtime exceptions go through directly.Catching
WrappedExceptionmay be used to unwrap expected throwable types.- Author:
- AO Industries, Inc.
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description WrappedException()Deprecated.Please provide cause.WrappedException(IOException cause)Deprecated.Please useUncheckedIOException.WrappedException(IOException cause, Object... extraInfo)Deprecated.Please useUncheckedIOException.WrappedException(String message)Deprecated.Please provide cause.WrappedException(String message, IOException cause)Deprecated.Please useUncheckedIOException.WrappedException(String message, IOException cause, Object... extraInfo)Deprecated.Please useUncheckedIOException.WrappedException(String message, Throwable cause)Uses extra info of the original cause when it is anExtraInfo.WrappedException(String message, Throwable cause, Object... extraInfo)WrappedException(Throwable cause)Uses extra info of the original cause when it is anExtraInfo.WrappedException(Throwable cause, Object... extraInfo)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static <V> Vcall(Callable<V> callable)Invokes the given callable, wrapping any checked exceptions.static <V> Vcall(Callable<V> callable, Object... extraInfo)Invokes the given callable, wrapping any checked exceptions.static <V> Vcall(Callable<V> callable, String message)Invokes the given callable, wrapping any checked exceptions.static <V> Vcall(Callable<V> callable, String message, Object... extraInfo)Invokes the given callable, wrapping any checked exceptions.static <V> VcallE(CallableE<V,?> callable)Invokes the given callable, wrapping any checked exceptions.static <V> VcallE(CallableE<V,?> callable, Object... extraInfo)Invokes the given callable, wrapping any checked exceptions.static <V> VcallE(CallableE<V,?> callable, String message)Invokes the given callable, wrapping any checked exceptions.static <V> VcallE(CallableE<V,?> callable, String message, Object... extraInfo)Invokes the given callable, wrapping any checked exceptions.Object[]getExtraInfo()Gets the optional extra info associated with an exception.StringgetLocalizedMessage()StringgetMessage()static voidrunE(RunnableE<?> runnable)Invokes the given runnable, wrapping any checked exceptions.static voidrunE(RunnableE<?> runnable, Object... extraInfo)Invokes the given runnable, wrapping any checked exceptions.static voidrunE(RunnableE<?> runnable, String message)Invokes the given runnable, wrapping any checked exceptions.static voidrunE(RunnableE<?> runnable, String message, Object... extraInfo)Invokes the given runnable, wrapping any checked exceptions.static <V> VwrapChecked(Callable<V> callable)Deprecated.Please usecall(java.util.concurrent.Callable)static <V> VwrapChecked(Callable<V> callable, Object... extraInfo)Deprecated.static <V> VwrapChecked(Callable<V> callable, String message)Deprecated.static <V> VwrapChecked(Callable<V> callable, String message, Object... extraInfo)Deprecated.-
Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
-
-
-
-
Constructor Detail
-
WrappedException
@Deprecated public WrappedException()
Deprecated.Please provide cause.
-
WrappedException
@Deprecated public WrappedException(String message)
Deprecated.Please provide cause.
-
WrappedException
public WrappedException(Throwable cause)
Uses extra info of the original cause when it is anExtraInfo.
-
WrappedException
@Deprecated public WrappedException(IOException cause)
Deprecated.Please useUncheckedIOException.
-
WrappedException
public WrappedException(Throwable cause, Object... extraInfo)
- Parameters:
extraInfo- No defensive copy
-
WrappedException
@Deprecated public WrappedException(IOException cause, Object... extraInfo)
Deprecated.Please useUncheckedIOException.
-
WrappedException
public WrappedException(String message, Throwable cause)
Uses extra info of the original cause when it is anExtraInfo.
-
WrappedException
@Deprecated public WrappedException(String message, IOException cause)
Deprecated.Please useUncheckedIOException.
-
WrappedException
public WrappedException(String message, Throwable cause, Object... extraInfo)
- Parameters:
extraInfo- No defensive copy
-
WrappedException
@Deprecated public WrappedException(String message, IOException cause, Object... extraInfo)
Deprecated.Please useUncheckedIOException.
-
-
Method Detail
-
call
public static <V> V call(Callable<V> callable)
Invokes the given callable, wrapping any checked exceptions.
-
wrapChecked
@Deprecated public static <V> V wrapChecked(Callable<V> callable)
Deprecated.Please usecall(java.util.concurrent.Callable)Invokes the given callable, wrapping any checked exceptions.
-
call
public static <V> V call(Callable<V> callable, Object... extraInfo)
Invokes the given callable, wrapping any checked exceptions.
-
wrapChecked
@Deprecated public static <V> V wrapChecked(Callable<V> callable, Object... extraInfo)
Deprecated.Invokes the given callable, wrapping any checked exceptions.
-
call
public static <V> V call(Callable<V> callable, String message)
Invokes the given callable, wrapping any checked exceptions.
-
wrapChecked
@Deprecated public static <V> V wrapChecked(Callable<V> callable, String message)
Deprecated.Invokes the given callable, wrapping any checked exceptions.
-
call
public static <V> V call(Callable<V> callable, String message, Object... extraInfo)
Invokes the given callable, wrapping any checked exceptions.
-
wrapChecked
@Deprecated public static <V> V wrapChecked(Callable<V> callable, String message, Object... extraInfo)
Deprecated.Invokes the given callable, wrapping any checked exceptions.
-
callE
public static <V> V callE(CallableE<V,?> callable)
Invokes the given callable, wrapping any checked exceptions.
-
callE
public static <V> V callE(CallableE<V,?> callable, Object... extraInfo)
Invokes the given callable, wrapping any checked exceptions.
-
callE
public static <V> V callE(CallableE<V,?> callable, String message)
Invokes the given callable, wrapping any checked exceptions.
-
callE
public static <V> V callE(CallableE<V,?> callable, String message, Object... extraInfo)
Invokes the given callable, wrapping any checked exceptions.
-
runE
public static void runE(RunnableE<?> runnable)
Invokes the given runnable, wrapping any checked exceptions.
-
runE
public static void runE(RunnableE<?> runnable, Object... extraInfo)
Invokes the given runnable, wrapping any checked exceptions.
-
runE
public static void runE(RunnableE<?> runnable, String message)
Invokes the given runnable, wrapping any checked exceptions.
-
runE
public static void runE(RunnableE<?> runnable, String message, Object... extraInfo)
Invokes the given runnable, wrapping any checked exceptions.
-
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
-
-