Hey Dan,

That's really not how you're supposed to do it. You should rather set your own errorcode in the constructor when throwing the exception. In my application (namely within a given controller) I throw an exception like this:

// [...]
throw new Zend_Controller_Exception("Oops! You're not supposed to be here.", 100);

Then, in the ErrorController I simply retrieve my errorcode and do whatever I want with it. You will note that $errors->exception->code is protected and hence not accessible. That's where the Exception::getCode() method comes in handy:

$errors = $this->_getParam('error_handler');
switch ($errors->exception->getCode())
{
  case 100:
         echo "Access denied.";
         break;
  default:
}

Alternatively you could work with your own constants too. Hope that helps.

Cheers
Bastian


On Aug 16, 2007, at 10:17 PM, Dan Rossi wrote:

Thanks matt, ill do the forwards in the caught exception, im not sure if Zend_Auth throw exceptions though.


Matthew Weier O'Phinney wrote:
-- Dan Rossi <[EMAIL PROTECTED]> wrote
(on Thursday, 16 August 2007, 07:33 PM +1000):

Hi trying to bubble an error when throwing something like this as Zend_Auth wont do it for u it seems

if (!$auth->hasIdentity())
       {
throw new Zend_Auth_Adapter_Exception("Not Allowed Access");
       }

The return type to the error controller is always EXCEPTION_OTHER. Id like it to be a EXCEPTION_AUTH_FAILED code or whatever so that i am able to display some custom template for a particular code / type.



switch ($exceptionType) {
               case 'Zend_Controller_Dispatcher_Exception':
                   $error->type = self::EXCEPTION_NO_CONTROLLER;
                   break;
               case 'Zend_Controller_Action_Exception':
                   $error->type = self::EXCEPTION_NO_ACTION;
                   break;
               default:
                   $error->type = self::EXCEPTION_OTHER;
                   break;
           }




Bastian Gerhard
Product Manager
__________________________________
Ashley Associates Ltd.
Technology Group

Minami-Aoyama First Building 8F
7-8-1 Minami-Aoyama
Minato-ku, Tokyo 107-0062

Reply via email to