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.
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.
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
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
[1] BadRequestException is a wrapper around jax-rs WebApplicationException where we set the Response status to be BAD_REQUEST (400).