Re: JSR311: Exception Handling

From: Marc Hadley <Marc.Hadley_at_Sun.COM>
Date: Tue, 01 Apr 2008 12:51:13 -0400

Also note that any entity you put in the Response returned by the
mapper will then be written by a suitable MessageBodyWriter. So you
can do something like:

public class ExceptionBackstop implements ExceptionMapper<Exception> {
   public Response map(Exception e) {return

public class XmlExceptionWriter implements
MessageBodyWriter<Exception> {...}

public class JsonExceptionWriter implements
MessageBodyWriter<Exception> {...}

public class TextExceptionWriter implements
MessageBodyWriter<Exception> {...}

The runtime will respect the Accept header when choosing the writer
for the response returned by the mapper and everything works as


On Apr 1, 2008, at 11:06 AM, Stephan Koops wrote:
> Also good.
> But IMO it should also allow to use other ExceptionMappers for the
> given Exception, if no one for the given media type is available.
> For this I proposed a finer differentiation, and not only true and
> false.
>> I suppose we could also allow use of @ProduceMime on the provider
>> class so the runtime can pick a suitable one but that could be OTT.
> Stephan
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

Marc Hadley <marc.hadley at>
CTO Office, Sun Microsystems.