Return-Path: X-Original-To: apmail-cocoon-dev-archive@www.apache.org Delivered-To: apmail-cocoon-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id B39B87149 for ; Mon, 19 Dec 2011 17:47:58 +0000 (UTC) Received: (qmail 13971 invoked by uid 500); 19 Dec 2011 17:47:58 -0000 Delivered-To: apmail-cocoon-dev-archive@cocoon.apache.org Received: (qmail 13873 invoked by uid 500); 19 Dec 2011 17:47:57 -0000 Mailing-List: contact dev-help@cocoon.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: dev@cocoon.apache.org List-Id: Delivered-To: mailing list dev@cocoon.apache.org Received: (qmail 13866 invoked by uid 99); 19 Dec 2011 17:47:57 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 19 Dec 2011 17:47:57 +0000 X-ASF-Spam-Status: No, hits=0.9 required=5.0 tests=RCVD_NUMERIC_HELO,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of ap-cocoon-dev@m.gmane.org designates 80.91.229.12 as permitted sender) Received: from [80.91.229.12] (HELO lo.gmane.org) (80.91.229.12) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 19 Dec 2011 17:47:51 +0000 Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1RchJ9-0001W5-4W for dev@cocoon.apache.org; Mon, 19 Dec 2011 18:47:27 +0100 Received: from 212.126.160.55 ([212.126.160.55]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 19 Dec 2011 18:47:27 +0100 Received: from andreas by 212.126.160.55 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 19 Dec 2011 18:47:27 +0100 X-Injected-Via-Gmane: http://gmane.org/ To: dev@cocoon.apache.org From: Andreas Hartmann Subject: [C3] Error handling in REST controller Date: Mon, 19 Dec 2011 18:47:12 +0100 Lines: 47 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: 212.126.160.55 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:8.0) Gecko/20111105 Thunderbird/8.0 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. WDYT? -- Andreas -- Andreas Hartmann, CTO BeCompany GmbH http://www.becompany.ch Tel.: +41 (0) 43 818 57 01