jOOL
jOOL copied to clipboard
Add Seq.peekThrowable(Consumer<Throwable>)
There is currently no fluent way of handling exceptions in a Stream
. While Stream
extends AutoCloseable
and provides an onClose(Runnable)
hook for actions that are to be taken before the actual closing, there is no such thing for exceptions.
We should add an peekThrowable(Consumer<Throwable>)
hook that allows Consumers
to be added to consume all sorts of exceptions that may occur.
The actual API is not yet fully defined and may differ, e.g. by taking inspiration from the Try
monad
@lukaseder, do you have any thoughts on this? I believe, CompletableFuture
's API is a rather well designed one, although a little bloated with (maybe) too much methods responsible for handling the computation result, so maybe this feature's implementation could borrow something from there?
I haven't thought all situations through yet. I'm afraid that it might not be a very good idea to implement such a method in a Stream
. Perhaps, there are situations where exceptions will escape...
An implementation suggestion was made by @tlinkowski in https://github.com/jOOQ/jOOL/pull/299
Implemented through https://github.com/jOOQ/jOOL/pull/315