title: Spring Webflux : Webclient : Get body on error
body: <p>I am using the webclient from spring webflux, like this :</p>
  
  <pre><code>WebClient.create()
              .post()
              .uri(url)
              .syncBody(body)
              .accept(MediaType.APPLICATION_JSON)
              .headers(headers)
              .exchange()
              .flatMap(clientResponse -&gt; clientResponse.bodyToMono(tClass));
  </code></pre>
  
  <p>It is working well. 
  I now want to handle the error from the webservice I am calling (Ex 500 internal error). Normally i would add an doOnError on the "stream" and isu the Throwable to test the status code, </p>
  
  <p>But my issue is that I want to get the body provided by the webservice because it is providing me a message that i would like to use.</p>
  
  <p>I am looking to do the flatMap whatever happen and test myself the status code to deserialize or not the body.</p>