Suppose this example of code:
aStream.foreach(object -> consumeObjectMayThrowCheckedException())
This will not compile because of the checked exception. I think that the state of art, in functional programming, is to process the stream, then get the list of thrown exception to handle it (let's say in order to log it). I've been using the following code, that I don't like:
String errorMessage = mylist.stream().map(my ->
Try.runWithCatch(() -> {
my.mayThrowCheckedException();
}, CheckedException.class)
)
.filter(Try::isFailure)
.map(t -> t.failureGet().orElse(new CheckedException("No exception")).getMessage())
.collect(Collectors.joining(", "));
What would be the proper to achieve it? What is the state of the art using Cyclops?
Thanks.
Suppose this example of code:
aStream.foreach(object -> consumeObjectMayThrowCheckedException())
This will not compile because of the checked exception. I think that the state of art, in functional programming, is to process the stream, then get the list of thrown exception to handle it (let's say in order to log it). I've been using the following code, that I don't like:
What would be the proper to achieve it? What is the state of the art using Cyclops?
Thanks.