Skip to content

Instantly share code, notes, and snippets.

@cilquirm
Last active September 24, 2015 14:18
Show Gist options
  • Save cilquirm/31dad05e44af3b89c9c2 to your computer and use it in GitHub Desktop.
Save cilquirm/31dad05e44af3b89c9c2 to your computer and use it in GitHub Desktop.
try example
Try.of( () -> somePotentiallyFatalOperation() )
.recover( (x) -> { logger.error("oops:",x); throw x; })
.orElse("Boo");
@danieldietrich
Copy link

You may use the onFailure method to peek a failure:

Try.of( () -> somePotentiallyFatalOperation() )
   .onFailure( x -> { logger.error("oops:",x); } )
   .orElse("Boo");

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment