Should JSON BodyParser return 400 if JSON parsing causes an exception?

When I am parsing custom classes with the default JSON BodyParser, if an exception is thrown during parsing - e.g. if my class has a require() condition which wasn’t met - a 500 is returned for the request. I think this scenario should return a 400 Bad Request - if attempting to parse the input to my custom type threw.

How can I extend the json BodyParser or create my own to achieve this?

Hi @mrubin
Well I dont think this is reponsability of Json Body parser. This should be handle in
https://www.playframework.com/documentation/2.8.x/ScalaErrorHandling#Supplying-a-custom-error-handler. Using that you can customize any exception before reaches the client. Than you can create an 400 exception with Json Body Parser error as cause.

example: BadRequestBodyException(message=“Wrong Body”, cause=JsonError)
something like that