0
votes

I am new to Reactive programming, so can use some help. I have below code where I am not liking two different methods for error handling. I want to combine them in one method. What is the correct approach?

mono.doOnError(error -> logError(error))
    .onErrorMap(
        t -> !(t instanceof DatabaseException),
           t -> DatabaseExceptionMapper.mapException(t));
1

1 Answers

2
votes

You can add the log in the onErrorMap itself.

flux.onErrorMap(err -> {
    logError(err);
    //return transformed exception
})