title: How to handle Spring Boot's redirection to /error?
body: <p>I've encountered the same issue as in <a href="https://stackoverflow.com/questions/28902374/spring-boot-rest-service-exception-handling">this question</a>, using Spring Boot 1.3.0 and not having my controllers annotated with <code>@RestController</code>, just <code>@Path</code> and <code>@Service</code>. As the OP in that question says,</p>
  
  <blockquote>
    <p>this is, to me, anything but sensible</p>
  </blockquote>
  
  <p>I also can't understand why would they have it redirect to /error. And it <strong>is very likely that I'm missing something</strong>, because I can only give back 404s or 200s to the client.</p>
  
  <p>My problem is that his solution doesn't seem to work with 1.3.0, so I have the following request flow: let's say my code throws a <code>NullPointerException</code>. It'll be handled by one of my <code>ExceptionMapper</code>s</p>
  
  <pre><code>@Provider
  public class GeneralExceptionMapper implements ExceptionMapper&lt;Throwable&gt; {
  
      private static final Logger LOGGER = LoggerFactory.getLogger(GeneralExceptionMapper.class);
  
      @Override
      public Response toResponse(Throwable exception) {
          LOGGER.error(exception.getLocalizedMessage());
          return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
      }
  }
  </code></pre>
  
  <p>And my code returns a 500, but instead of sending it back to the client, it tries to redirect it to /error. If I don't have another resource for that, it'll send back a 404.</p>
  
  <pre><code>2015-12-16 18:33:21.268  INFO 9708 --- [nio-8080-exec-1] o.glassfish.jersey.filter.LoggingFilter  : 1 * Server has received a request on thread http-nio-8080-exec-1
  1 &gt; GET http://localhost:8080/nullpointerexception
  1 &gt; accept: */*
  1 &gt; host: localhost:8080
  1 &gt; user-agent: curl/7.45.0
  
  2015-12-16 18:33:29.492  INFO 9708 --- [nio-8080-exec-1] o.glassfish.jersey.filter.LoggingFilter  : 1 * Server responded with a response on thread http-nio-8080-exec-1
  1 &lt; 500
  
  2015-12-16 18:33:29.540  INFO 9708 --- [nio-8080-exec-1] o.glassfish.jersey.filter.LoggingFilter  : 2 * Server has received a request on thread http-nio-8080-exec-1
  2 &gt; GET http://localhost:8080/error
  2 &gt; accept: */*
  2 &gt; host: localhost:8080
  2 &gt; user-agent: curl/7.45.0
  
  2015-12-16 18:33:37.249  INFO 9708 --- [nio-8080-exec-1] o.glassfish.jersey.filter.LoggingFilter  : 2 * Server responded with a response on thread http-nio-8080-exec-1
  2 &lt; 404
  </code></pre>
  
  <p>And client's side (curl):</p>
  
  <pre><code>$ curl -v http://localhost:8080/nullpointerexception
  * STATE: INIT =&gt; CONNECT handle 0x6000572d0; line 1090 (connection #-5000)
  * Added connection 0. The cache now contains 1 members
  *   Trying ::1...
  * STATE: CONNECT =&gt; WAITCONNECT handle 0x6000572d0; line 1143 (connection #0)
  * Connected to localhost (::1) port 8080 (#0)
  * STATE: WAITCONNECT =&gt; SENDPROTOCONNECT handle 0x6000572d0; line 1240 (connection #0)
  * STATE: SENDPROTOCONNECT =&gt; DO handle 0x6000572d0; line 1258 (connection #0)
  &gt; GET /nullpointerexception HTTP/1.1
  &gt; Host: localhost:8080
  &gt; User-Agent: curl/7.45.0
  &gt; Accept: */*
  &gt;
  * STATE: DO =&gt; DO_DONE handle 0x6000572d0; line 1337 (connection #0)
  * STATE: DO_DONE =&gt; WAITPERFORM handle 0x6000572d0; line 1464 (connection #0)
  * STATE: WAITPERFORM =&gt; PERFORM handle 0x6000572d0; line 1474 (connection #0)
  * HTTP 1.1 or later with persistent connection, pipelining supported
  &lt; HTTP/1.1 404 Not Found
  * Server Apache-Coyote/1.1 is not blacklisted
  &lt; Server: Apache-Coyote/1.1
  &lt; Content-Length: 0
  &lt; Date: Wed, 16 Dec 2015 17:33:37 GMT
  &lt;
  * STATE: PERFORM =&gt; DONE handle 0x6000572d0; line 1632 (connection #0)
  * Curl_done
  * Connection #0 to host localhost left intact
  </code></pre>
  
  <p>So it's always a 404. Unless I do have such an /error resource, then what? what am I supposed to return? All I have at that point is a GET request to /error. And I don't want those extra requests consuming resources and polluting my logs.</p>
  
  <p>What am I missing? And if nothing, what should I do with my exception handling?</p>