From the course: Java EE: RESTful Service with JAX-RS 2.0

Unlock the full course today

Join today to access over 22,500 courses taught by industry experts or purchase this course individually.

How to handle errors

How to handle errors

From the course: Java EE: RESTful Service with JAX-RS 2.0

Start my 1-month free trial

How to handle errors

- [Narrator] Things don't always go as planned with your code. Sometimes a client requests a resource that does not exist, sometimes unauthorized requests are made, or perhaps an exception is thrown because there is an issue with the database. Let's take a look at how errors and exceptions can be handled. There are four exception handling approaches that you can choose from. Do nothing and let the container take care of the exception. Catch the exception and respond to the client with the appropriate configured response object. Wrap the exception in the web application exception object and let JAX-RS handle it. Or manage the exception by registering an exception manager. We're going to examine each of the methods and then decide which is the most appropriate to implement in the bookshop application. So, first off, let's examine the option of doing nothing. An exception that is propagated to the container is dealt with by the servlet layer and the status code 500 Internal Server Error…

Contents