2

I try to wrap exception that thrown in Mono into another exception. I try to use onErrorResume() and doOnError() methods, but it does not help. How can I do it?

 return response
                .handle((responseData, sink) -> handleStatus(data, logContext, sink))
                .doOnError(v -> {
                    throw new CriticalException("str", "str", "str", "str", "str", "str");
                });
petrov.aleksandr
  • 622
  • 1
  • 5
  • 24

1 Answers1

4

Ideally use onErrorResume(), resuming to a publisher that supplies your new error as so:

.onErrorResume(e -> Mono.error(new CriticalException()))
Michael Berry
  • 70,193
  • 21
  • 157
  • 216