dev@jersey.java.net

Re: WebApplicationException alternative suggestion

From: Adam Walczak <ja_at_adamwalczak.info>
Date: Mon, 22 Nov 2010 16:41:27 +0100

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.

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