From wink-user-return-417-apmail-incubator-wink-user-archive=incubator.apache.org@incubator.apache.org Wed May 23 10:41:26 2012 Return-Path: X-Original-To: apmail-incubator-wink-user-archive@minotaur.apache.org Delivered-To: apmail-incubator-wink-user-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 6C96CCEB5 for ; Wed, 23 May 2012 10:41:26 +0000 (UTC) Received: (qmail 57396 invoked by uid 500); 23 May 2012 10:41:26 -0000 Delivered-To: apmail-incubator-wink-user-archive@incubator.apache.org Received: (qmail 57312 invoked by uid 500); 23 May 2012 10:41:25 -0000 Mailing-List: contact wink-user-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: wink-user@incubator.apache.org Delivered-To: mailing list wink-user@incubator.apache.org Received: (qmail 57301 invoked by uid 99); 23 May 2012 10:41:25 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 23 May 2012 10:41:25 +0000 X-ASF-Spam-Status: No, hits=2.2 required=5.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of anton.piatek@uk.ibm.com designates 195.75.94.110 as permitted sender) Received: from [195.75.94.110] (HELO e06smtp14.uk.ibm.com) (195.75.94.110) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 23 May 2012 10:41:14 +0000 Received: from /spool/local by e06smtp14.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 23 May 2012 11:40:54 +0100 Received: from d06nrmr1307.portsmouth.uk.ibm.com (9.149.38.129) by e06smtp14.uk.ibm.com (192.168.101.144) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 23 May 2012 11:40:51 +0100 Received: from d06av10.portsmouth.uk.ibm.com (d06av10.portsmouth.uk.ibm.com [9.149.37.251]) by d06nrmr1307.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q4NAeod62670626 for ; Wed, 23 May 2012 11:40:50 +0100 Received: from d06av10.portsmouth.uk.ibm.com (loopback [127.0.0.1]) by d06av10.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q4NAVOad001809 for ; Wed, 23 May 2012 06:31:24 -0400 Received: from d06ml014.portsmouth.uk.ibm.com (d06ml014.portsmouth.uk.ibm.com [9.149.104.45]) by d06av10.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id q4NAVO2X001806 for ; Wed, 23 May 2012 06:31:24 -0400 X-Disclaimed: 10622 To: wink-user@incubator.apache.org MIME-Version: 1.0 Subject: custom exception mappers and core exceptions/errors X-KeepSent: B894364D:D4FA6300-80257A07:0039B1C7; type=4; name=$KeepSent X-Mailer: Lotus Notes Release 8.5.3 September 15, 2011 From: Anton Piatek1 Message-ID: Date: Wed, 23 May 2012 11:40:42 +0100 X-MIMETrack: Serialize by Router on D06ML014/06/M/IBM(Release 8.5.2FP1 ZX852FP1HF12|September 28, 2011) at 23/05/2012 11:40:43, Serialize complete at 23/05/2012 11:40:43 Content-Type: multipart/alternative; boundary="=_alternative 003AAAFF80257A07_=" x-cbid: 12052310-1948-0000-0000-000001E151E9 This is a multipart message in MIME format. --=_alternative 003AAAFF80257A07_= Content-Type: text/plain; charset="US-ASCII" I am trying to use a custom exception mapper to format all exceptions into my desired xml/json types depending on the content type. I am handling my own exceptions happily and returning the http status code I want, and the right xml/json response with the right helper messages, but when it comes trying to catch wink errors such as a url/method/body being wrong and not matching a handler I am struggling. I want to handle these myself because wink does not format them into xml/json, and if it did, would still be choosing its own format rather than mine. I have an exceptionMapper which handles WebApplicationException but from the exception I get there, I cannot figure out how to get a description of the cause. I can get the stack, which normally isn't helpful, and I can get the http status code from the response, but trying to get a string saying "there is no handler for method PUT on resource /wibble/" seems to be impossible. Has anyone attempted this? Did you find a solution? The closest I can get is parsing the http status code and writing a description stream for each, but then I have to parse the Request object to work out what the user called. I would have thought wink has already done some of this for me. Anton Unless stated otherwise above: IBM United Kingdom Limited - Registered in England and Wales with number 741598. Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6 3AU --=_alternative 003AAAFF80257A07_= Content-Type: text/html; charset="US-ASCII" I am trying to use a custom exception mapper to format all exceptions into my desired xml/json types depending on the content type.

I am handling my own exceptions happily and returning the http status code I want, and the right xml/json response with the right helper messages, but when it comes trying to catch wink errors such as a url/method/body being wrong and not matching a handler I am struggling. I want to handle these myself because wink does not format them into xml/json, and if it did, would still be choosing its own format rather than mine.

I have an exceptionMapper which handles WebApplicationException but from the exception I get there, I cannot figure out how to get a description of the cause. I can get the stack, which normally isn't helpful, and I can get the http status code from the response, but trying to get a string saying "there is no handler for method PUT on resource /wibble/" seems to be impossible.

Has anyone attempted this? Did you find a solution?

The closest I can get is parsing the http status code and writing a description stream for each, but then I have to parse the Request object to work out what the user called. I would have thought wink has already done some of this for me.

Anton





Unless stated otherwise above:
IBM United Kingdom Limited - Registered in England and Wales with number 741598.
Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6 3AU






--=_alternative 003AAAFF80257A07_=--