title: The ResponseEntity returned by @ExceptionHandler in @ControllerAdvice can't be shown in swagger-ui.html
body: <p>The Response returned by @ExceptionHandler for MaxUploadSizeExceededException in @ControllerAdvice can't be shown in swagger-ui.html.</p>
  
  <p>I am using Spring Boot for my RESTful Application. And using swagger-ui to use the RESTful APIs. One of my RESTful API is upload file, using Spring's MultipartFile.</p>
  
  <p>The file size is limited, and when the uploaded file size exceeds the limit, there will be an exception as below thrown.
  [Request processing failed; nested exception is org.springframework.web.multipart.MaxUploadSizeExceededException: Maximum upload size exceeded...</p>
  
  <p>To handle this exception to return an customized error message to client, I used the @ExceptionHandler in @ControllerAdvice to return the response. Below is my code.</p>
  
  <pre><code>    @ControllerAdvice
      public class GlobalControllerExceptionHandler{
          @ExceptionHandler(MaxUploadSizeExceededException.class)
          @ResponseBody
          public ResponseEntity&lt;?&gt; maxUploadSizeExceededException(MaxUploadSizeExceededException e) {        
              String bodyJson = "{\"ErrorMessage\":\"Maximum upload size exceeded.\"}";
              return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).contentType(MediaType.TEXT_PLAIN).body(bodyJson);
          }
      }
  </code></pre>
  
  <p>What I want to see in swagger-ui.html is like this:</p>
  
  <pre><code>    Response Body:
      {"ErrorMessage":"Maximum upload size exceeded."}
  
      Response Code:
      500
  </code></pre>
  
  <p>But now, I didn't see any content:</p>
  
  <pre><code>    Response Body:
      no content
  
      Response Code:
      0
  </code></pre>
  
  <p>One abnormal symptom I saw on Browser console is that, thet request header </p>
  
  <p>Provisional headers shows "Provisional headers are shown":</p>
  
  <pre><code>!Provisional headers are shown
  Accept: */*
  Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryf7WjEeoDHtIm3ly1
  Origin: http://localhost:8080
  Referer: http://localhost:8080/SpringApp/swagger-ui.html
  User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36
  X-Requested-With: XMLHttpRequest
  </code></pre>
  
  <p>I searched about "Provisional headers are shown", someone explains that, if such message shows, it means the request is actually not sent. But on my case, I actually got the requst on my Spring Application server side and I can even hit the @ErrorHandler method "maxUploadSizeExceededException".</p>