Class CatchAndRethrowClosure<E>

  • All Implemented Interfaces:

    public abstract class CatchAndRethrowClosure<E>
    extends Object
    implements Closure<E>
    Closure that catches any checked exception and re-throws it as a FunctorException runtime exception. Example usage:
     // Create a catch and re-throw closure via anonymous subclass
     CatchAndRethrowClosure<String> writer = new ThrowingClosure() {
         private out = // some writer
         protected void executeAndThrow(String input) throws IOException {
             out.write(input); // throwing of IOException allowed
     // use catch and re-throw closure
     java.util.List<String> strList = // some list
     try {
         CollectionUtils.forAllDo(strList, writer);
     } catch (FunctorException ex) {
         Throwable originalError = ex.getCause();
         // handle error
    • Constructor Detail

      • CatchAndRethrowClosure

        public CatchAndRethrowClosure()
    • Method Detail

      • execute

        public void execute​(E input)
        Execute this closure on the specified input object.
        Specified by:
        execute in interface Closure<E>
        input - the input to execute on
        FunctorException - (runtime) if the closure execution resulted in a checked exception.