public static < T > Try < T > to ( FuncE0 < T , Exception > code , ActionE0 < Exception > onFinally ) { try { return new Success <> ( code . call ( ) ) ; } catch ( Exception e ) { return new Failure <> ( e ) ; } finally { if ( onFinally != null ) { try { onFinally . call ( ) ; } catch ( Exception e ) { LogFactory . from ( Try . class ) . trace ( ) . log ( e . getMessage ( ) , e ) ; } } } }
Constructs a Try using a code as a supplier .