On Fri, Jul 30, 2010 at 4:50 PM, Paul Sandoz <Paul.Sandoz_at_oracle.com> wrote:
>
> On Jul 30, 2010, at 3:41 PM, Alexandru Popescu ☀ wrote:
>
>> Upon further (re)search it looks like most of the posters talking
>> about a similar solution are solving it by using exceptions and
>> ExceptionMapper.
>>
>> Probably because I hate programming through exception, I've thought
>> about a different approach based on container response filters.
>> Basically, using a special container response filter would allow me to
>> customize both the Response and the Entity according to the app needs.
>>
>> Is this the right direction?
>>
>
> I think it depends on how you are returning 4xx/5xx responses.
>
> If you are using an exception already e.g. WebApplicationException then it
> may make more sense. Note that you can also write a general mapper for
> WebApplicationException that supports what you require and then you can
> extend from WebApplicationException or not if you wish. This has the added
> advantage of capturing exceptions thrown by Jersey. Any exception thrown by
> Jersey intended to be mapped to a response will always extend from
> WebApplicationException.
>
> If not the filter approach may better suite your requirements.
>
> Paul.
>
Thanks Paul. I'd say that a generic solution requires both approaches.
And this is the path I'm taking now. I've already tested the filter
part and it works as expected.
:- alex
>
>> :- alex
>>
>>
>> 2010/7/30 Alexandru Popescu ☀ <the.mindstorm.mailinglist_at_gmail.com>:
>>>
>>> Hi,
>>>
>>> I was wondering if there is any way I can map error status codes to
>>> special resources that are able to return a more useful/friendlier
>>> responses?
>>>
>>> Basically what I want to achieve is that for any resource returning
>>> say a 404, I could intercept this and provide a better/friendlier
>>> response. A good example would be to provide a better looking 404 page
>>> for text/html requests.
>>>
>>> I've read about the ExceptionMapper and this seems to be good for
>>> dealing with exceptions, but not with statuses.
>>>
>>> Am I looking in the right direction or are there better ways to deal with
>>> this?
>>>
>>> many thanks in advance,
>>>
>>> :- alex
>>>
>>
>> ---------------------------------------------------------------------
>> 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
>
>