title: How to rethrow exception as @ResponseStatus-annotated exception in Spring @ExceptionHandler?
body: <p>I have made exception, that I'm throwing always when I want a 404 page:</p>
  
  <pre><code>@ResponseStatus( value = HttpStatus.NOT_FOUND )
  public class PageNotFoundException extends RuntimeException {
  </code></pre>
  
  <p>I want to create controller-wide <code>@ExceptionHandler</code> that will re-throw <code>ArticleNotFoundException</code>(which causes error 500) as my 404 exception:</p>
  
  <pre><code>@ExceptionHandler( value=ArticleNotFoundException.class )
  public void handleArticleNotFound() {
      throw new PageNotFoundException();
  }
  </code></pre>
  
  <p>But it doesn't work - I still have <strong>error 500</strong> and Spring logs:</p>
  
  <p><code>ExceptionHandlerExceptionResolver - Failed to invoke @ExceptionHandler method: ...</code></p>
  
  <p>Note that I translate code to html so response cannot be empty or simple String like with <code>ResponseEntity</code>. <code>web.xml</code> entry:</p>
  
  <pre><code>&lt;error-page&gt;
      &lt;location&gt;/resources/error-pages/404.html&lt;/location&gt;
      &lt;error-code&gt;404&lt;/error-code&gt;
  &lt;/error-page&gt;
  </code></pre>
  
  <p><strong>FINAL SOLUTION FROM ANSWER COMMENTS</strong></p>
  
  <p>It's not a full re-throw, but at least it uses <code>web.xml</code> error page mapping like my <code>PageNotFoundException</code></p>
  
  <pre><code>    @ExceptionHandler( value = ArticleNotFoundException.class )
      public void handle( HttpServletResponse response) throws IOException {
          response.sendError( HttpServletResponse.SC_NOT_FOUND );
  
      }
  </code></pre>