title: Add a body to a 404 Not Found Exception
body: <p>In an REST API generated with JHipster, I want to throw some 404 exceptions. It is normally done with</p>
  
  <pre><code>return new ResponseEntity&lt;&gt;(HttpStatus.NOT_FOUND);
  </code></pre>
  
  <p>which actualy results in a 404 response to the xhr request. The problem is that in the front side, JHipster parses the response with </p>
  
  <pre><code>angular.fromJson(result)
  </code></pre>
  
  <p>and such result is empty when the 404 is the actual response, which makes the parse to fail.</p>
  
  <p>If I point to an unmapped URI, lets say <code>/api/user</code> while my controller maps to <code>/api/users</code> (note the plural) the 404 I got from the API has a body in it:</p>
  
  <pre><code>{
      "timestamp": "2016-04-25T18:33:19.947+0000",
      "status": 404,
      "error": "Not Found",
      "message": "No message available",
      "path": "/api/user/myuser/contact"
  }
  </code></pre>
  
  <p>which is correctly parse in angular.</p>
  
  <p>How can I create a body like this? Is this exception thrown by spring or is tomcat who throws it?</p>
  
  <p>I tried this: <a href="https://stackoverflow.com/questions/2066946/trigger-404-in-spring-mvc-controller">Trigger 404 in Spring-MVC controller?</a> but I cant set the parameters of the response.</p>