title: Spring ignores my CustomErrorController
body: <p>In my SpringBoot project, I have a CustomErrorController that is mapped to "/error". But for some reason, Spring goes directly to the error.html page. I've read that SpringBoot automatically goes to the error.html page when present, but i'd like it to pass through my CustomErrorController to add a customer errorMsg:</p>
  
  <pre><code>public class CustomErrorController implements ErrorController {
  
  private static final String PATH = "/error";
  
  @RequestMapping(value = PATH)
  public ModelAndView renderErrorPage(HttpServletRequest httpRequest) {
      System.out.println("In the ErrorController");
      ModelAndView errorPage = new ModelAndView("error");
      String errorMsg = "";
      int httpErrorCode = getErrorCode(httpRequest);
  
      switch (httpErrorCode) {
          case 400: {
              errorMsg = "Http Error Code: 400. Bad Request";
              break;
          }
          case 401: {
              errorMsg = "Http Error Code: 401. Unauthorized";
              break;
          }
          case 404: {
              errorMsg = "Http Error Code: 404. Resource not found";
              break;
          }
          case 405: {
              errorMsg = "Http Error Code: 405. User not found";
              break;
          }
          case 500: {
              errorMsg = "Http Error Code: 500. Internal Server Error";
              break;
          }
          default: {
              errorMsg = "Something broke";
          }
      }
      errorPage.addObject("errorMsg", errorMsg);
      return errorPage;
  }
  
  private int getErrorCode(HttpServletRequest httpRequest) {
      return (Integer) httpRequest
              .getAttribute("javax.servlet.error.status_code");
  }
  
  @Override
  public String getErrorPath() {
      return PATH;
  }
  }
  </code></pre>
  
  <p>I'm using this method to throw an exception:</p>
  
  <pre><code>@RequestMapping(value = "/forgot", method = RequestMethod.POST)
  public ModelAndView processForgotPasswordForm(ModelAndView modelAndView, 
   @RequestParam("email") String userEmail) throws NotFoundException, 
   IOException {
  
      // Gebruiker opzoeken in de datebase
      User user = userService.findByEmail(userEmail);
  
      if (user == null) {
          throw new NotFoundException("User Not Found");
  </code></pre>
  
  <p>and this is my error.html page:</p>
  
  <pre><code>&lt;div class="container"&gt;    
  &lt;div th:action="@{/error}"&gt;
      &lt;h1&gt;ERRORMESSAGE&lt;/h1&gt;
      &lt;p th:text="${errorMsg}"&gt;&lt;/p&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p></p>
  
  <p>This results in the error.hmtl page being show, but only with the ERRORMESSAGE, no errorMsg is show but this is probably because my CustomErrorController is skipped.</p>
  
  <p>EDIT:</p>
  
  <p>Some additional info, when I rename the error.html to something else, a whitelabel error page is shown that says there is no default mapping for /error, which is odd because my CustomErrorController does provide this?</p>
  
  <p>EDIT2:</p>
  
  <p><strong><em>The above code is working, just in case someone else stumbles upon the same issue.</em></strong></p>