ErrorHandler plugin is designed to
handle HTTP 404-type errors (page missing) and 500-type errors (internal
error). It is not intended to catch exceptions raised in other plugins
or routing.
ErrorController::errorAction() in the default
module. You may set alternate values for these by using the various
accessors available to the plugin:
setErrorHandlerModule() sets the controller module
to use.
setErrorHandlerController() sets the controller
to use.
setErrorHandlerAction() sets the controller action
to use.
setErrorHandler() takes an associative array, which
may contain any of the keys 'module', 'controller', or 'action',
with which it will set the appropriate values.
setErrorHandler().
postDispatch() hook and checks for exceptions registered in
the response object. If
any are found, it attempts to forward to the registered error handler
action.
ErrorHandler plugin captures not only
application errors, but also errors in the controller chain arising
from missing controller classes and/or action methods, it can be
used as a 404 handler. To do so, you will need to have your error
controller check the exception type.
$errors->type. It will be one of the following:
exception property of the
error_handler object:
render(), it's possible that the
response object already has content stored within it. This can lead
to rendering a mixture of expected content and error content.
The page you requested was not found.
EOH; break; default: // application error $content =<<An unexpected error occurred. Please try again later.
EOH; break; } // Clear previous content $this->getResponse()->clearBody(); $this->view->content = $content; } } ]]>