java - Handling and Mapping Runtime Exceptions in REST Resource to JAX-RS Response - Stack Overflow
Just have your exception class extend WebApplicationException
and throw it wherever you like. You can see in the example below that you can customize the response in whatever way is necessary. Happy coding!
Note: this example handles 403
errors, but you can easily create exceptions to handle 500
, 503
, etc.
Read full article from java - Handling and Mapping Runtime Exceptions in REST Resource to JAX-RS Response - Stack Overflow
No comments:
Post a Comment