I think that this should be implemented in DS instead. The place where
DS exception handling should hook into JAX-RS (ExceptionMapper) is the
very place where the ResponseBuilder producer should be provided.
On 08/13/2012 01:35 PM, Pete Muir wrote:
We would need an extension that supported this.
I talked to Jozef a short while back, and we discussed adding the support from Seam 3
REST into RESTEasy's CDI support directly. Not sure when this will happen though.
Jozef?
On 6 Aug 2012, at 13:13, Marek Schmidt wrote:
> On 03/08/12 20:36, Pete Muir wrote:
>> * I'm not handling bad responses in the UI at all. Please tell me what to do
someone :-)
> In Seam3 REST, it was possible to inject the ResponseBuilder in the
> ExceptionHandler, would something similar be possible in DS?
>
>
>
> See:
>>
https://github.com/seam/rest/blob/develop/examples/exceptions/src/main/ja...
>> import javax.ws.rs.core.MediaType;
>> import javax.ws.rs.core.Response.ResponseBuilder;
>>
>> import org.jboss.solder.exception.control.CaughtException;
>> import org.jboss.solder.exception.control.Handles;
>> import org.jboss.solder.exception.control.HandlesExceptions;
>> import org.jboss.seam.rest.exceptions.ExceptionMapping;
>> import org.jboss.seam.rest.exceptions.RestResource;
>>
>> @HandlesExceptions
>> @ExceptionMapping.List({
>> @ExceptionMapping(exceptionType = IllegalAccessException.class, status =
403),
>> @ExceptionMapping(exceptionType = NullPointerException.class, status =
500, message = "NullPointerException was thrown."),
>> @ExceptionMapping(exceptionType = RuntimeException.class, status = 500,
useExceptionMessage = true)})
>> public class CatchExceptionHandlers {
>> public void arithmeticExceptionHandler(@Handles
CaughtException<ArithmeticException> event,
>> @RestResource ResponseBuilder builder)
{
>> builder.status(500).entity("Cannot divide by zero. Want to divide by
two instead?").type(MediaType.TEXT_PLAIN_TYPE);
>> event.handled();
>> }
>> }
>
> --
> Marek Schmidt
> Seam QE