16 Error handling
16.1 Different ways of handling error situations
When a
-
Produce the complete error response: set the appropriate status code and a response body.
-
Throw an exception. Catching the exception and creating the appropriate response becomes the responsibility of a downstream filter.
-
Set only the response status, but not the response body. The Restlet API allows the status to include a custom description and a Throwable object. Creating the response body becomes the responsibility of a downstream filter.
16.1.1 Case 1: resource class produces complete error response
This is interesting if you want to provide very specific error responses. This will especially be useful in Webservice (REST-API) style resources, and less for user-facing web applications.
If a resource class formats all errors it might produce itself, it is completely self-contained without relying on any downstream filters to do further work for them.
Previous