Maybe I am not understanding the question, but I think you can return
a JSONWithPadding in the toResponse method of the
ExceptionMapper<YourException>:
return Response.status(YOUR_STATUS_CODE)
.type("application/json")
.entity(new JSONWithPadding(yourJSONObject, yourCallback) ).build();
If the problem is to propagate the JS callback from the request, one
possible solution if you're using Spring would be to use a
request-scoped object injected (as an scoped proxy) both in the Jersey
resource and in the ExceptionMapper - put there everything you need
(the JS callback you got in the request, for example) and use it in
the ExceptionMapper.
Francisco A. Lozano
On Wed, Feb 15, 2012 at 04:22, Ed Anuff <ed_at_anuff.com> wrote:
> I'm wondering what the best way is to handle exceptions when using JSONP?
> I'm thinking that the best thing to do is to return a proper JSONP result
> with an error code inside of the response, but I can't really see how that
> would be accomplished with the existing ExceptionMapper mechanism. Is there
> a way to do this?
>
> Ed