budjb / grails-jaxrs

JAX-RS Plugin for Grails

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Improved exception handling in JSONReader and XMLReader

budjb opened this issue · comments

From @trpedersen on August 26, 2013 6:27

Hi,

Thanks for the good work with this plugin - it is working well for us.

An improvement though - if a client programs sends through invalid JSON or XML then the JSONReader and XMLReader code falls over with an uncaught exception (e.g. JsonException) causing an HTTP 500 error back at the client. IMHO this should be instead caught and send back to the client as a BAD_REQUEST (or similar) message, rather than a server error.

The two ..readFrom methods should catch any exceptions raised during xml or json parsing and wrap them in a WebApplicationException with the appropriate Response+status+entity+type set.

I've worked around it by using ExceptionMappers for now..

Tim Pedersen

Copied from original issue: krasserm#25

From @noamt on September 2, 2013 8:2

Thanks for the feedback; I'll take a look at better handling for these cases