Error handling in JAX-RS

In this section, we're going to take a look at handling user and server-side errors in a RESTful way by using an appropriate HTTP status code, for example, HTTP status code 400 Bad Request for invalid and malformed requests, status 404 Not Found if something could not be found, and HTTP status code 500 Internal Server Error if something happens unexpectedly. We'll also see how to use WebApplicationException and its subclasses to model error handling, and finally we'll be implementing a custom ExceptionMappers to handle runtime exceptions and return custom error responses:

Conceptual view of this section

This is what ...

Get Building RESTful Web Services with Java EE 8 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.