On Dec 14, 2009, at 7:33 PM, Casper Bang wrote:
> I implemented a 400 ExceptionMapper in order to adhere to REST
> best-practices, upon receiving a semantically incorrect request:
>
> @Provider
> public class SemanticExceptionMapper implements
> ExceptionMapper<SemanticException> {
> @Override
> public Response toResponse(SemanticException ex) {
> return Response.status(400)
> .entity(ex.getMessage())
> .type("text/plain")
> .build();
> }
> }
>
> It works fine except very little (well nothing) of the error message
> is
> revealed to the user.
You mean the entity, ex.getMessage(), is not received by the client?
It should not make any different if an exception is mapped to a
response or a such an equivalent response is returned directly from a
resource method.
As a quick sanity check you may want to enable Jersey response logging
just to verify Jersey is not doing something odd.
I just tried a quick test with Tomcat 6.0.20 and it worked fine for me.
Paul.
> This could be container specific I suppose (I'm
> using Tomcat 6.x) or a visibility/security issue. Would anyone know
> about this? The specs says "...may contain a document describing why
> the
> server thinks there's a client-side error".
>
> Thanks in advance,
> Casper
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>