All pastes #971553 Raw Edit

Simple error controller

public php v1 · immutable
·published 2008-04-04 20:46 UTC
rendered paste body
<?php/** * Default_ErrorController.php1 * */class ErrorController extends Zend_Controller_Action{    /**     * Assigns controller scope view variables and set layout template     *     */    public function init() {        //set page title        $this->view->headTitle('Error');        //use error layout        $this->_helper->layout->setLayout('error');    }    /**     * Formats error report with backtrace and exception dump     *     */    public function errorAction()    {        $errors = $this->_getParam('error_handler');        switch ($errors->type) {            case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER:            case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION:                // 404 error -- controller or action not found                $this->getResponse()->setRawHeader('HTTP/1.1 404 Not Found');                $content ='<h1>Error - 404</h1><br />';                $content .='<p>' . $errors->exception->getMessage() . '</p>';                break;            default:                // application error                $content = '<h1>Unexpected Error!</h1><br />';                $content .= '<p>' . $errors->exception->getMessage() . '</p>';                break;        }        // Clear previous content        $this->getResponse()->clearBody();        $this->view->content = $content;        $this->view->error = $errors;    }}//the view<?php echo $this->content; ?><h2>Backtrace</h2><pre style="font-size:small;"><?php debug_print_backtrace();?></pre><br /><h2>Error Dump</h2><pre style="font-size:small;"><?php var_dump($this->error);?></pre>