I'm working with CakePHP 2.0 and want to handle a ForbiddenException. I've followed the example explained at the CakePHP Cookbook.
My exception is now caught at the AppExceptionHandler but I don't know how to move from here. I want to render a relevant View but $this
is not available.
Does anyone have a starting point for me?
Edit:
My code so far is identical to the Cookbook example:
In app/Config/core.php
Configure::write('Exception.handler', 'AppExceptionHandler::handle');
In app/Config/bootstrap.php
App::uses('AppExceptionHandler', 'Lib');
In app/Lib/AppExecptionHandler.php
class AppExceptionHandler {
public static function handle($error) {
if($error instanceOf ForbiddenException ){
echo 'Oh noes! ' . $error->getMessage();
// $this->Session->setFlash('To access the page please login');
}
}
}
regards, Bart