Reputation: 697
I read the official document of PlayFramework about Error handling. And I learned it is good to use HttpErrorHandler
class. And they say such error handling classes can catch errors or exceptions from Action
. And I saw methods of DefaultHttpErrorHandler
class. However, how does the DefaultHttpErrorHandler
class distinguish errors or exceptions thrown from Action
? Some method such as onServerError
takes int
argument as its parameter, so in this case how does Action
throw errors or exceptions? Does other page show it?
Upvotes: 3
Views: 1028
Reputation: 1196
Basically, an exception thrown in a Controller will result of a 500 http error code. The onServerError
method will catch and handle this exception.
On the other side, 400, 401, 403 or 404 http error codes are called "Client error" in Play environnement. These errors are catch and handle by the onClientError
method.
Thus, if you want to have a dedicated and customized page for 404 http error page ("Page not found"), build the given view and call it inside the onClientError
method (you have the statusCode
parameter to distinct 404 from 400, 401 or other http status code).
If you want to have a custom error page, you have to call the dedicated view in onServerError
method.
Upvotes: 1