Here is the boilerplate code: I want to do something like this -
public Flux<Object2> getSomething(String email) {
method1(email).map(result -> { //method1 returns Mono<Object1>
if(result.id().isEmpty()) {
return method2(email); //method2 returns Flux<Object2>
} else {
return Flux.empty();
}
};
});
So, when method1 returns an empty Object1.id(), then only call method2. Else return empty Flux.
Pointers to note are -
It is not reaching the second method call
Since one method is Mono and the other is Flux, there is a type mismatch if I directly add return in line 2.
I tried with this in method1 :
if(Object1.id().isEmpty()){ throw new IllegalArgumentException; }
and in above code snippet :
try {
method1(email);
} catch(IllegalArgumentException e) {
return method2(email);
}
Never catches exception here.