From the course: Java EE: RESTful Service with JAX-RS 2.0
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Implement an exception manager
From the course: Java EE: RESTful Service with JAX-RS 2.0
Implement an exception manager
- [Instructor] Okay let's implement the final exception handling option and create an exception manager. An exception we want to handle is the ISBN not found exception. This has already been created in the exception package, so let's create a class and I'm going to call this class ISBN not found exception manager. ISBN Exception Not Found Manager. This class must implement the exception mapper interface. The type that we need to pass to the exception mapper is exception that we wish to map. In this case it's gonna be ISBN not found exception. There is only one method that we need to implement, and that's the two response method. In this method all we have to do is to return our response with the appropriate ATTP code. Which in this case I want to be no content. So we do return response status I want no content and we call the build method to construct it. The final thing we need to do is to add a provider annotation to the class. Now all we need to do is to change the code so that…
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)
-
-
-