0

I want to handle standard http errors the same way. How can I do it with Spring WebClient? Instead of hanging status check on each call below

webClient.get()
    .uri("http://localhost:8081/resource")
    .retrieve()
    .onStatus(HttpStatus::isError, clientResponse -> {
        // some error handling logic
    })
    .bodyToMono(MyPojo.class);
ntviet18
  • 752
  • 1
  • 10
  • 26
  • If your `webClient` is a `singleton`, you can add `ExchangeFilterFunction.ofResponseProcessor` filter to webclient on bean creation where you can write common error handling logic for all webservice calls. – akreddy.21 May 08 '19 at 06:35

1 Answers1

0

Solution based on @akreddy.21's comment

Add ExchangeFilterFunction.ofResponseProcessor filter to webclient on bean creation where you can write common error handling logic for all webservice calls.

ntviet18
  • 752
  • 1
  • 10
  • 26