handling of exceptions

Bryan Kearney bkearney at redhat.com
Tue Mar 23 18:19:33 UTC 2010


On 03/23/2010 01:54 PM, Jesus M. Rodriguez wrote:
> In a discussion with Prad, Adrian asked how we should handle
> exceptions in candlepin.
> Right now we seem to throw BadRequestException[1] whenever we have a problem.
>
> The idea is we want to send back a 400 (or other proper HTTP code),
> then the client
> can read the response. In the response we want a JSON string that they can read
> what really happened.

would it be based on the media type? Today, it is xml by default.. json 
is specified.

>
> Unfortunately, our current implementation yields a plain text string
> (not json) even
> if I change the code to be .type("application/json"). But if I pass a
> jaxb object to the
> Exception class it gets serialized properly.

See above.

>
> So we'll create a ExceptionMessage object that can be jaxbified, that
> would contain
> the following attributes:
>     name i.e. "invalid_argument"
>     message i.e. text string as to what happened
>     display message i.e. text string that can be displayed to the user

localized??

>
> Then BadRequestException (and other wrapped exceptions) will contain an
> ExceptionMessage object inside.
>
> A few things need to happen in this as well:
>
> * need to figure out proper HTTP error codes and WHEN to send them
> * create ExceptionMessage class
> * create the wrapper exception classes
>

When? Part of next sprint?

-- bk




More information about the candlepin mailing list