2.10. Error Handling

If an Exception occurs processing a Page object or rendering a template the error is delegated to the registered handler. The default Click error handler is the ErrorPage, which is automatically configured as:

<page path="click/error.htm" classname="org.apache.click.util.ErrorPage"/>

To register an alternative error handler you must subclass ErrorPage and define your page using the path "click/error.htm". For example:

<page path="click/error.htm" classname="com.mycorp.page.ErrorPage"/>

When the ClickServlet starts up it checks to see whether the error.htm template exists in the click web sub directory. If it cannot find the page the ClickServlet will automatically deploy one. You can tailor the click/error.htm template to suite you own tastes, and the ClickServlet will not overwrite it.

The default error template will display extensive debug information when the application is in development or debug mode. Example error page displays include:

When the application is in production mode only a simple error message is displayed. See Configuration for details on how to set the application mode.

Please also see the Examples web app Exception Demo for demonstrations of Clicks error handling.