edu.rice.cs.plt.lambda
Class WrappedException
java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
edu.rice.cs.plt.lambda.WrappedException
- All Implemented Interfaces:
- Serializable
public class WrappedException
- extends RuntimeException
A wrapper for checked exceptions, allowing them to be thrown by lambda code (and in other situations
in which an interface does not allow checked exceptions to be thrown).
Clients should check for the expected exception type with code like the following:
try { ... }
catch (WrappedException e) {
if (e.getCause() instanceof SomeCheckedException) { throw (SomeCheckedException) e.getCause(); }
else { throw e; }
}
Unfortunately, the Java language does not allow abstraction over exception types — a method cannot
be declared to throw a variable type — so a generic version of the above block of code
cannot be included as a method here.
- See Also:
- Serialized Form
| Methods inherited from class java.lang.Throwable |
fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString |
WrappedException
public WrappedException(Throwable cause)