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
From the course: Java EE: RESTful Service with JAX-RS 2.0
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…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
(Locked)
The HTTP response4m 24s
-
(Locked)
Build a response3m 24s
-
(Locked)
How to handle errors3m 19s
-
(Locked)
Implement an exception manager2m 46s
-
(Locked)
Work with HATEOAS4m 21s
-
(Locked)
HATEOAS and JAX-RS2m 59s
-
(Locked)
Add HATEOAS to the resource10m 33s
-
(Locked)
Challenge: Add exception handlers19s
-
(Locked)
Solution: Add exception handlers1m 2s
-
(Locked)
-
-
-