title: JAX-RS / Jersey how to customize error handling?
body: <p>I'm learning JAX-RS (aka, JSR-311) using Jersey. I've successfuly created a Root Resource and am playing around with parameters:</p>
  
  <pre><code>@Path("/hello")
  public class HelloWorldResource {
  
      @GET
      @Produces("text/html")
      public String get(
          @QueryParam("name") String name,
          @QueryParam("birthDate") Date birthDate) {
  
           // Return a greeting with the name and age
      }
  }
  </code></pre>
  
  <p>This works great, and handles any format in the current locale which is understood by the Date(String) constructor (like YYYY/mm/dd and mm/dd/YYYY). But if I supply a value which is invalid or not understood, I get a 404 response.</p>
  
  <p>For example:</p>
  
  <pre class="lang-none prettyprint-override"><code>GET /hello?name=Mark&amp;birthDate=X
  
  404 Not Found
  </code></pre>
  
  <p>How can I customize this behavior? Maybe a different response code (probably "400 Bad Request")? What about logging an error? Maybe add a description of the problem ("bad date format") in a custom header to aid troubleshooting? Or return a whole Error response with details, along with a 5xx status code?</p>