The only thing I worry about is whether they will be able to make this change
in a backwards-compatible way. It's really too bad they already speced
returning null or throwing an exception from the method.
Gili
Paul Sandoz wrote:
>
>
> On Oct 3, 2008, at 2:55 PM, Gili wrote:
>
>>
>>
>> This is definitely problematic. I posted this RFE on the jsr311
>> mailing
>> list. Hopefully they'll add it in before their final release.
>>
>
> Unfortunately JSR 311 is already final. It will need to be considered
> as part of the maintenance release (which is also the release that
> will align with Java EE 6).
>
> Paul.
>
>> Gili
>>
>>
>> Paul Sandoz wrote:
>>>
>>> Hi Gili,
>>>
>>> It is currently not possible to limit trapping of exceptions to
>>> certain packages.
>>>
>>> On Oct 3, 2008, at 5:07 AM, Gili wrote:
>>>
>>>>
>>>> I've found a solution that works for now:
>>>>
>>>> @Provider
>>>> public class RuntimeExceptionMapper implements
>>>> ExceptionMapper<RuntimeException>
>>>> {
>>>> @Inject
>>>> private static Exceptions exceptions;
>>>>
>>>> @Override
>>>> public Response toResponse(RuntimeException exception)
>>>> {
>>>> if (exception instanceof WebApplicationException)
>>>> {
>>>> WebApplicationException internalException =
>>>> (WebApplicationException)
>>>> exception;
>>>> return internalException.getResponse();
>>>> }
>>>> ResponseBuilder builder =
>>>> Response.status(Status.INTERNAL_SERVER_ERROR);
>>>> builder.type(MediaType.TEXT_PLAIN_TYPE);
>>>> builder.entity(exceptions.getStackTrace(exception));
>>>> return builder.build();
>>>> }
>>>> }
>>>>
>>>> This assumes that all internal exceptions (whether thrown by Jersey,
>>>> Resteasy or any other implementation) will extend
>>>> WebApplicationException.
>>>
>>> WebApplicationException is only mapped if there is no entity present
>>> (i need to check if this matches the specified behaviour).
>>>
>>> Jersey also throws ContainerException that is for the HTTP containers
>>> to catch, for example the Servlet container will re-throw that as a
>>> wrapped ServletException. But in your case you still might want to
>>> trap this.
>>>
>>> The set of RuntimeException classes that may be thrown is
>>> implementation specific.
>>>
>>> Paul.
>>>
>>>> I
>>>> don't think the specification requires this to be true (any thoughts
>>>> on
>>>> this?), but it seems to at least be the case for Jersey.
>>>>
>>>> Thanks,
>>>> Gili
>>>>
>>>>
>>>>
>>>> Gili wrote:
>>>>>
>>>>> Hi,
>>>>>
>>>>> I want to provide a ExceptionMapper<RuntimeException> that catches
>>>>> all
>>>>> RuntimeExceptions except those in packages javax.ws.rs.** or
>>>>> com.sun.jersey.**. How do I implement this?
>>>>>
>>>>> I'm worried this isn't covered by the JSR311 design :(
>>>>>
>>>>> Thank you,
>>>>> Gili
>>>>>
>>>>
>>>> --
>>>> View this message in context:
>>>> http://n2.nabble.com/How-to-tell-ExceptionMapper-to-exclude-exceptions--tp1140399p1140805.html
>>>> Sent from the Jersey mailing list archive at Nabble.com.
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
>>>> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
>>> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>>>
>>>
>>>
>>
>> --
>> View this message in context:
>> http://n2.nabble.com/How-to-tell-ExceptionMapper-to-exclude-exceptions--tp1140399p1141903.html
>> Sent from the Jersey mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
>> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>
>
>
--
View this message in context: http://n2.nabble.com/How-to-tell-ExceptionMapper-to-exclude-exceptions--tp1140399p1300740.html
Sent from the Jersey mailing list archive at Nabble.com.