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.
Solution: Add exception handlers
From the course: Java EE: RESTful Service with JAX-RS 2.0
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…
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)
-
-
-