wink-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Anton Piatek1 <anton.pia...@uk.ibm.com>
Subject Re: custom exception mappers and core exceptions/errors
Date Wed, 23 May 2012 13:38:18 GMT
Thanks Serafin, I will keep this solution in mind.

Regards, 

Anton




From:   Serafin Sedano <serafin.sedano@abiquo.com>
To:     wink-user@incubator.apache.org, 
Date:   23/05/2012 14:34
Subject:        Re: custom exception mappers and core exceptions/errors



As I said our requirements was quite different. But in case you could not 
achieve it with just exceptionMapper (which I don't know) I let you know 
how our custom solution could help you.

Regards.

Serafín.

2012/5/23 Anton Piatek1 <anton.piatek@uk.ibm.com>
So you couldn't do it just in an exceptionMapper? I was hoping to avoid 
having to rewrite too much of the core wink dispatcher, but it sounds like 
you went in deep and extended the internals. 

Surely there must be a way to achieve this without having to extend the 
RequestProcessor and DeploymentConfiguration. 

Regards, 

Anton 



From:        Serafin Sedano <serafin.sedano@abiquo.com> 
To:        wink-user@incubator.apache.org, 
Date:        23/05/2012 14:21 
Subject:        Re: custom exception mappers and core exceptions/errors 




Hi,  

We've done something similar. 

We extended RequestProcessor and DeploymentConfiguration. Then in the 
constructor ExtendedRequestProcessor we set our 
ExtendedDeploymentConfiguration. 

What did the trick for us was to extend the ResourceRegistry and add it in 
the ExtendedDeploymentConfiguration. This ExtendedResourceRegistry has 
the findMethod and findSubResourceMethod custom implementation that allows 
the throw of our own Exception. 

Regards. 

Serafín.

2012/5/23 Anton Piatek1 <anton.piatek@uk.ibm.com> 
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 








-- 
Serafín Sedano | Software Engineer | Abiquo |  | serafin.sedano@abiquo.com 






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 









-- 
Serafín Sedano | Software Engineer | Abiquo |  | serafin.sedano@abiquo.com






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






Mime
View raw message