Quantcast

Should Grails throw an exception if there is a JSON parsing error?

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Should Grails throw an exception if there is a JSON parsing error?

anilj
I have noticed  that "Error parsing JSON" ConverterException  is caught but not re-thrown in Grails.

It is just logged by Grails if I let it parse the request and build the command object. It builds a new command object will all null fields.

I can change my Controller code to explicitly parse the request using "new MyCommand(request.JSON)" and handle the exception in a try and catch block. However, I want to avoid doing that and instead have Grails build my command object as it is now. I can understand that it would be rare to get invalid JSON as most of the apps would be generating the JSON, but wouldn't it be good to re-throw the exception or provide a way to configure the desired behavior, something like throwParseError=true/false?

Loading...