@ SafeVarargs @ SuppressWarnings ( "unchecked" ) public static < T extends Exception > Optional < T > firstFail ( ActionE0 < T > ... tasks ) { for ( ActionE0 < T > task : tasks ) { try { task . call ( ) ; } catch ( Exception t ) { return Optional . of ( ( T ) t ) ; } } return Optional . empty ( ) ; }
Run the given tasks until any exception happen