2

JAX-RS has a general WebApplicationException class for encapsulating any HTTP response status code and reason phrase. But there are many code-specific subclasses. For example NotFoundException indicates an HTTP 404 not found response code, although one could have created a general WebApplicationException instance with a response code of 404.

Is there some simple way for me to take a non-success HTTP response code and create the appropriate WebApplicationException subclass (one of those defined in the JAX-RS API)? Or am I forced to create a factory method with a big switch statement to do this?

Garret Wilson
  • 18,219
  • 30
  • 144
  • 272

0 Answers0