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

Unlock the full course today

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

Solution: Add exception handlers

Solution: Add exception handlers

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

Start my 1-month free trial

Solution: Add exception handlers

(digital music) - [Narrator] So how did you get along with this challenge? Your challenge was to add error handlers where appropriate. Now your solution might differ slightly from mine. So I'm just going to show you what I did. Here in the older class, I decided I wanted to throw an AuthorIDNotRecognizedException, if an ID was passed into the getAuthor method that was not recognized. So what I had to do was to create an AuthorIDNotRecognizedException, and here in the getAuthor method, all I've had to do is throw that exception, and also what I need to do is to create an exception manager. So I'll open up the Exception Manager and show you what that looks like. So here in the Exception Manager, all I've done is to create an AuthorIDNotRecognizedExceptionManager and implement the Exception Manager interface. And I've passed into that the exception that I want it to handle. I've implemented the method to response, and within that method, all I'm doing is I'm responding back to the client…

Contents