On 10-04-12 3:56 PM, Bryan Kearney wrote:
On 04/12/2010 01:41 PM, Dmitri Dolguikh wrote:
I committed the first cut of parseable exceptions. The 'interesting' parts:
CandlepinExceptionMapper.java - the bit that maps exceptions thrown by Resources to http responses CandlepinException.java - base class for exceptions BadRequestException.java - I modified just one exception to be handled by the ExceptionMapper, as a trial/demo
Looks good all and all. One comments.. is the label meant to be the ID? If so, should we have a list of valid ids?
I'm not sure. I thought it was short message/long message. More or less for disambiguation of http return codes.
please note that CandlepinExceptionMapper had to be registered via guice (see CandlepinModule.java).
And guice looks for all folks who implement the mapper? Is this injected at every method boundary?
Binding the mapper using guice triggers registration of Provider (in resteasy lingo), which exception mapper is. Exception mapper handles the conversion of exceptions to responses (& JAXB handles serialization). I made a common super-class for candlepin exceptions to be thrown by Resources, and that exception mapper will handle them all (so no additional mapping is required for the rest of the exceptions).
-d