Reputation: 78441
In a Play Framework controller, how do I map exceptions to HTTP result codes? For example, if calling any action results in a MyDataLayer.EntityNotFound
, I want the HTTP result to be 404 not found
. Does Play provide way to map exception types to HTTP result codes?
(I am using Play 2.1.1.)
Upvotes: 3
Views: 475
Reputation: 741
You can override the onError
callback defined in play.api.GlobalSettings to handle the error and return appropriate HTTP status code.
Upvotes: 4