On Nov 22, 2010, at 4:41 PM, Adam Walczak wrote:
> Hmm. Are the processors in your proposal:
>
>> class MyExceptionHandler implements Handle<ME> {
>> // inject what you want and use it here
>> public void handle(ME ex) {
>> }
>> }
>
> something different from from standard JAX-RS exception mappers:
>
> @Provider
> public class MyExceptionMapper implements
> ExceptionMapper<MyException> {
>
> @Override
> public Response toResponse(MyException e) {
> }
> }
>
> To me they seam to represent the same concept and possibilities.
> Please correct me if I'm wrong.
>
They seem similar to me as well.
Alexandru Popsecu has also proposed some improvements to exception
mapping that has some similarities with what you are proposing:
http://jots.mypopescu.com/post/1031879539/my-experience-with-jersey-jax-rs
This is a good idea and i think would make, at least initially, most
sense as a separate module. We could place such a module in the
experimental area until we are happy with it.
I prefer Alexandru's approach of using an ErrorInfo class for the
entity rather than a Throwable.
Paul.
> In my solution I just want to add an easy method to set the status
> code per exception class. I think it's something you do commonly and
> you should have to create a separate class just to do that.
>
> And I want to change the way Jersey handles all exceptions. Not just
> mine exceptions.
>
> I think the current behaviour of Jersey where the HTTP status code is
> the only information you have about the exception is to little and
> it's not common case.
> To me Jersey should output the exception details in either json or xml
> or the exceptions message in plain text. I think this is a common case
> when Jersey is used as a web framework or when it's just an REST API.
> I'd like this to become the default behaviour or an enable feature in
> the configuration params. Like for example:
>
> com.sun.jersey.config.feature.ExceptionOutput = none | plain_text |
> json | xml
>
> 'none' could be the current behaviour
>
> --
> Adam Walczak
> www.adamwalczak.info
> +48 604 188 992