views:

46

answers:

1

I'm trying to use the Zend_Controller_Plugin_ErrorHandler to handle my error 404 cases. According to the doc, the plugin has constants that one can use to match Exception types and handle them accordingly. e.g.

switch ($errors->type) {
        case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ROUTE:
        case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER:
        case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION:
            // 404 error -- controller or action not found

Does anyone know how to create exceptions of these types specifically?

+2  A: 

You can do like this:

 $this->getResponse()->setHttpResponseCode(404);

or

 throw new Zend_Controller_Action_Exception(‘This page dont exist’,404)
Vaidas Zilionis