Play CMS has a set of predefined errors and error screens that can be used (or extended).
Use the Error helper class (from a controller) like this:
// Returns the error screen with a 500 internal server error response code return Error.internal("My error message");
Currently, these exist:
Return the ErrorPage object with key _internalError (the default error page blocks are created during setup)
The ErrorPage template (by default) shows the error number to all, and the error message only to admin users
Log the error message and create a unique error number as reference:
[error] application - _internalError #1400678401348: Could not find homepage (page block with key 'homepage')
To create custom error screens / templates in your project:
ErrorPagesubclass which uses your template
DefaultBootstrapper#getErrorPageInstance()to return an instance of your custom error page
Note: For more control, you can also overwrite the
Don't forget to call /reset to have your new error pages created.
These error screens are also cms pages, which means admins can add or modify their content, translate them etc. Edit them from the cms backend, they're placed under the System node in the navigation tree.