Hi,

One option is to register your own WebApplicationExceptionMapper which will return only the status for all cases (same as the default one) except for a case when a caught WebApplicationException contains Response with 403. If WebApplication is thrown from a RequestHandler then the simpler option would be to return a non-null Response with 403 and some text/entity object as needed as opposed to throwing an exception...

cheers, Sergey


----- Original Message ----- From: "KARR, DAVID (ATTCINW)" <[email protected]>
To: <[email protected]>
Sent: Thursday, January 21, 2010 4:36 PM
Subject: Strategies for mapping exceptions


I know the basic idea is to use an ExceptionMapper, but I'm trying to
decide what the best strategies are for working with this.

For instance, my current test case is getting a 403 status on an invalid
request. My application determines this dynamically and throws a
WebApplicationException with a FORBIDDEN response status.  If I do
nothing else, the client gets the 403 back, but with an empty response.
It's possible that's ok, but perhaps not.  I was wondering whether I
should construct a reasonable-looking "error" object with an exception
mapper.  I suppose if I want to map that specific scenario I'll have to
manually create a "AccessDeniedException", like Spring Security uses
(I'm not going to integrate that just for one exception class :) ), and
create the mapper with that.  Otherwise, I can only map
WebApplicationException, which is too generic for this particular case,
although I might want a more general solution for that.

What do people do in this area?

Reply via email to