<?php

class ErrorController extends Fiktiv_Controller_Action
{
    public function errorAction()
    {
        $error = $this->_getParam('error_handler');

        // display debug information if we are in a developer environment.
        if (ini_get('display_errors')) {
            $this->_helper->layout->setLayout('clean');
            $this->view->error = $error;
            $this->render('debug');
            return;
        }

        switch($error->type) {
            // 404 - Page not found
            case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION :
            case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER :
            case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ROUTE :
                $this->_forward('page-not-found');
                break;
            // 500 - Application error
            default :
                $this->getResponse()->setHttpResponseCode(500);
        }
    }

    public function pageNotFoundAction()
    {
        $this->getResponse()->setHttpResponseCode(404);
    }
}