title: How to access the RequestBody in a Spring WebFlux @ExceptionHandler?
body: <p>Is there a way to get access to the <code>RequestBody</code> (preferably in it's mapped form) in an <code>@ExceptionHandler</code> method using Spring WebFlux, with the default Reactor Netty?</p>
  
  <p>Consider the following example:</p>
  
  <pre><code>@RestController
  class TestRestController {
  
    @PostMapping("/test")
    Mono&lt;TestBody&gt; testPost(@RequestBody TestBody testBody) {
      return Mono.error(new NullPointerException());
    }
  
    @ExceptionHandler(NullPointerException.class)
    @ResponseStatus(HttpStatus.BAD_REQUEST)
    Mono&lt;Void&gt; handleNullPointerException(ServerWebExchange serverWebExchange) {
      return Mono.empty();
    }
  
  }
  </code></pre>
  
  <p>At runtime additional instances of <a href="https://docs.spring.io/spring/docs/current/spring-framework-reference/web-reactive.html#webflux-ann-arguments" rel="noreferrer">certain types</a> can be injected into the <code>@ExceptionHandler</code>'s method signature, as shown in the above example with <code>ServerWebExchange</code>. But the docs clearly state that it doesn't support request body arguments (see the note in <a href="https://docs.spring.io/spring/docs/current/spring-framework-reference/web-reactive.html#webflux-ann-controller-exceptions" rel="noreferrer">this section</a>).</p>
  
  <p>Using the Servlet stack, you can inject the <code>RequestContext</code> as <a href="https://stackoverflow.com/a/46046430/1930325">shown here</a>. Is there an equivalent or similar approach for the WebFlux stack?</p>