In my Dropwizard project, I'm defining a generic ExceptionMapper<WebApplicationException>
:
environment.jersey().register(new WebApplicationExceptionMapper());
...but this doesn't seem to catch any of the 404 errors for unmatched paths.
Without defining five defaultHandler()
methods for every single resource, how do I catch all 404s so I can return my own error page or some JSON?
So, if I had a service with one resrouce, say, /docs
, this is the situtation:
/myservice/docs/helloworld
doesn't match any@Path
defined in my DocsResource. It returns a generic Jetty 404 page (not what I want)/myservice/doesntexist
returns my own error resource with the exception mapper (this is what I want everywhere)