Feb 21, 2024
Great explanation , thanks a lot.
We faced this "pitfall" when we needed to customize the error messages for users , when an error is thrown with switchIfEmpty(Mono.error(...)) and it proved impossible to get the current user via ReactiveSecurityContextHolder.
Finally solved it by passing the main context to the new stream via Mono.deferContextual( switchIfEmpty((Mono.error(...context here...)))) and carrying it on a field in our Custom Exception