JAX-RS / Jersey how to customize error handling?
There are several approaches to customize the error handling behavior with JAX-RS. Here are three of the easier ways. The first approach is to create an Exception class that extends WebApplicationException. Example: public class NotAuthorizedException extends WebApplicationException { public NotAuthorizedException(String message) { super(Response.status(Response.Status.UNAUTHORIZED) .entity(message).type(MediaType.TEXT_PLAIN).build()); } } And to throw this newly create Exception you simply: … Read more