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.

Implement an exception manager

Implement an exception manager

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

Start my 1-month free trial

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…

Contents