TODO: this is just a generated example
Added in version 2.5.0
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.