From the course: Java EE 8: Web Services

Unlock the full course today

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

Error handling in JAX-RS

Error handling in JAX-RS - Java EE Tutorial

From the course: Java EE 8: Web Services

Start my 1-month free trial

Error handling in JAX-RS

- [Instructor] At some point everything breaks and so will most web services. Not yours, obviously, but just on the off chance that it does, what you don't want is to send an unsightly error page, stack trace, or worse to the client. What you do want is to fail gracefully, respond with a coherent error message, and not reveal any sensitive application information to the client. This video is going to show you how to use the JAX-RS Exception Mapper to gracefully and safely handle failures in your web application. We start with the vanilla Java class. So I'm going to start here, create a new Java class, let's call it the Exception Handler. I want it in the rest dot exceptions package. Next step, I'm going to implement the Exception Mapper interface from the Java X, dot WS, dot RS, dot EXT package. So let's implement Exception Mapper. Let's fixed that import. Let's save this first. And fix the import. From the…

Contents