HappyPath<Happy, Sad> happyAttempt(Attempt<Happy>, Exception, Sad>)

TODO: this is just a generated example

javadoc usage tests

Added in version 2.5.0

Happy attempt can fail and map technical failure to a sad path

Attempt<Happy> attempt = () -> {throw new RuntimeException("message");};
Mapping<Exception, Sad> sadMapping =  technicalFailure -> new Sad(technicalFailure.getMessage());

HappyPath<Happy, Sad> happyPath = HappyPath.happyAttempt(attempt, sadMapping);

assertThat(happyPath.getSad()).hasToString("message");

In this case, the technical failure is mapped to a sad path that contains the exception message.