cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andreas Hartmann <>
Subject [C3] Error handling in REST controller
Date Mon, 19 Dec 2011 17:47:12 GMT
Hi all,

I just noticed that if a handler method in a RESTController throws an 
exception and the sitemap doesn't contain an error handler, an empty 
response with status code 200 is returned.

IMO this is not good. I see two approaches to improve it:

A) The SpringRESTController sets the status code to 500 if an exception 
was thrown by the controller implementation.

B) The sitemap processor should catch the exception (I'm not familiar 
with the implementation details yet) and send an appropriate response 
(on a side note, it would be nice to be able to set the status-code 
attribute for a Reader).

I have to admit that the whole concept how the REST controller in 
combination with the sitemap should handle the request-response cycle is 
a bit unclear to me. Is the REST controller always in charge of the 
whole request-response cycle, up to setting the response status code? Is 
the handle-errors element in the sitemap obsolete when the REST 
controller is used?

IMO this would make sense, since the REST controller is much closer to 
the HTTP details than "classic" G-T-S pipelines, where more stuff 
happened in the sitemap (selectors for HTTP methods, serializers with 
status-code attributes).

Anyways, there should be a clear contract between the sitemap and the 
REST controller, something like:

* The REST controller is responsible for setting up the response, 
including error handling.

* The handle-errors clause kicks in if an error occurs in the REST 
controller itself.


-- Andreas

Andreas Hartmann, CTO
BeCompany GmbH
Tel.: +41 (0) 43 818 57 01

View raw message