I am learning about error handling using Flux/Mono and have this problem:
Flux.just("AAA", "BBB", "AAA", "CCC")
.map(s -> {
if (s.equals("AAA")) {
throw new IllegalArgumentException();
}
return s;
})
.map(s -> s + "-LOL")
.onErrorMap(IllegalArgumentException.class, cause -> new IllegalStateException())
.onErrorContinue(IllegalArgumentException.class, (e, a) -> System.out.println("Found IllegalArgumentException" + e))
.onErrorContinue(IllegalStateException.class, (e, a) -> System.out.println("Found IllegalStateException" + e))
.collectList()
.block();
What I am trying to do is map an error exception to another exception and then I want to handle it in a specific way.
In my code, I see that onErrorContinue
is triggered only for IllegalArgumentException
, but I don't understand why - I've just mapped the error to IllegalStateException