edu.rice.cs.plt.lambda
Class WrappedException

java.lang.Object
  extended by java.lang.Throwable
      extended by java.lang.Exception
          extended by java.lang.RuntimeException
              extended by 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

Constructor Summary
WrappedException(Throwable cause)
           
 
Method Summary
 
Methods inherited from class java.lang.Throwable
fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

WrappedException

public WrappedException(Throwable cause)