I'm trying to log at each failure stage and, as far as I can tell, I need to nest the try and log inside a flatmap.
Try.of(() -> true).
onFailure(h -> System.out.println("first onFailure")).
flatMap(i -> Try.of(() -> { throw new RuntimeException(); }).
onFailure(j -> System.out.println("second onFailure"))).
flatMap(k -> Try.of(() -> true).
onFailure(l -> System.out.println("third onFailure")));
Is there an easier way to do it than the above? Is there a function in the library that I can use to replace the nested Try.of()
s?