@ Cmd public void optional ( final Closure < Void > closure ) { log . info ( "Executing optional block ..." ) ; try { closure . call ( ) ; } catch ( final Exception ex ) { log . error ( "Exception executing optional block: " + ex . getMessage ( ) , ex ) ; errors . add ( ex ) ; } catch ( AssertionError err ) { log . error ( "Assertion failed executing optional block: " + err . getMessage ( ) , err ) ; errors . add ( err ) ; } log . info ( "... finished execution of optional block" ) ; }
Runs the specified closure catching any exception that might occur during execution .