| | |
|
|
|
HTTP error handling
When problems occur on a Web site, error pages should be returned to the client.
You can use the rendering capabilities to provide custom error pages.
Rendering error pages
To display an error page, use the following required steps:
- Set the status code:
/request/status
- Set the value of
/request/view to error.
- Invoke zero.core.views.ViewEngine.render()
request.status = 404
... // set any header values here
request.view = "error"
render()
Naming error pages
Error pages can be scripts, templates or HTML. You must place all error pages in your
app/errors directory. An error page can represent a specific error code, the class of codes, or
a default page for all error codes.
<appRoot>
+ app/
+ errors/
- error404.groovy error page for status code = 404
- error5XX.gt error page for any error code >= 500 and < 600
- error.html default error page for all error codes
For any error code, the following set of error pages are searched for location, in the following order:
- error<status code>.<extension>
- error<class of status code>.<extension>
- error.<extension>.
The extension is determined by the extension search order, which is stored in the global context at /config/fileserver/defaultExtensions.
Error pages from dependencies
If the error page cannot be found in your application, the dependencies of your application
are also searched using virtualized directories.
zero.core provides a set of default error pages that the application can override.
zero.core.webtools provides a default error page. The default error page allows you to set a message, /request/error/message, and exception, /request/error/exception, to include in the resulting page.
|
|
r12 - 29 Jan 2008 - 19:57:49 - paynel
|
|
|
| | |