-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce assorted Reactor error handling Refaster rules #318
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rebased and added a commit. Suggested commit message:
Introduce assorted Reactor error handling Refaster rules (#318)
static final class MonoOnErrorResume<T> { | ||
@BeforeTemplate | ||
Mono<T> before(Mono<T> mono, Class<? extends Throwable> clazz, Mono<T> other) { | ||
return mono.onErrorResume(clazz::isInstance, e -> other); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of e -> other
we should use Function<? super Throwable, ? extends Mono<? extends T>> fallback
here, as that way we also support non-lambda function arguments.
@@ -676,6 +676,19 @@ Flux<T> after(Flux<T> flux) { | |||
} | |||
} | |||
|
|||
/** Drop redundant {@link Class#isInstance} in {@link Mono#onErrorResume(Function)}. */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mono#onErrorResume(Function)
isn't the overload that's invoked 🙃
@@ -676,6 +676,19 @@ Flux<T> after(Flux<T> flux) { | |||
} | |||
} | |||
|
|||
/** Drop redundant {@link Class#isInstance} in {@link Mono#onErrorResume(Function)}. */ | |||
static final class MonoOnErrorResume<T> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should add similar rules for a few other overload pairs that accept a Class
and a Predicate
. And likewise for Flux
:)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Phew 😆
That's quite a lot that you added :D
I was wondering indeed if there was a set of those methods that we should cover 😬
Guess that was the case 😅
Thanks ;) I could've done it though ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No worries!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Appreciating the fallback
Function though, I was trying to find a nice way to do it, this is definitely cleaner.
@BeforeTemplate | ||
Mono<T> before( | ||
Mono<T> mono, Class<? extends Throwable> clazz, Consumer<? super Throwable> onError) { | ||
return mono.doOnError(clazz::isInstance, onError); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Next to clazz::isInstance
users may also write t -> t instanceof clazz
. Rather than adding Refaster.anyOf
in a bunch of places, let's instead add a BugChecker
that maps the latter to the former. (For technical reasons IIUC we can't do this with Refaster.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll work on this on a separate PR 👌
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
... and that PR is #323 :)
1d0e338
to
8e061ba
Compare
8e061ba
to
809beb2
Compare
809beb2
to
c73bd48
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes LGTM!
Nice @Stephan202 that you added even more cases :).
Will merge once 🟢! |
::isInstance
in onErrorResume
No description provided.