AxonFramework / AxonFramework

Framework for Evolutionary Message-Driven Microservices on the JVM
https://axoniq.io/
Apache License 2.0
3.32k stars 790 forks source link

[#3123] Introduce `SubscriptionQueryResult#handle` default implementation that expects a `Consumer<Throwable>` #3124

Closed smcvb closed 1 month ago

smcvb commented 1 month ago

The SubscriptionQueryResult#handle(Consumer<? super I>, Consumer<? super U>) would swallow exceptions that reside in the Mono<I> initialResult. As this is not helpful to the end user, this pull request provides an implementation of SubscriptionQueryResult#handle(...) that expects a Consumer<Throwable> to be given.

This so-called errorConsumer is invoked when subscribing the initialResult() generates an exception, when subscribing to the updates() generates an exception, and when the initialResultConsumer or updateConsumer throw an exception. As such, the errorConsumer is invoked each time the SubscriptionQueryResult#cancel would be triggered.

Lastly, this PR deprecates SubscriptionQueryResult#handle(Consumer<? super I>, Consumer<? super U>) in favor of SubscriptionQueryResult#handle(Consumer<? super I>, Consumer<? super U>, Consumer<Throwable>) to ensure users think consciously about dealing with exceptions.

By doing the above, this pull request resolves #3123.