I am using cakephp, I working on Error Handling
I have follow http://book.cakephp.org/1.3/en/view/1188/Error-Handling
I have create AppError My code is
app/app_error.php
<?php
class AppError extends ErrorHandler {
function error404() {
//$this->controller->set('file', $params['file']);
$this->_outputMessage('error404');
}
}
?>
I am calling this error404 from my controller
function userprofile($id = null) {
$user = $this->Session->read('user');
if($id != $user['User']['id'])
{
$this->cakeError('error404');
}
}
but I found Erro
Fatal error: Call to undefined method UsersController::cakeError() in D:\wamp\www\survey\app\Controller\UsersController.php on line 318
I miss some thing?
I think you are using CakePHP 1.3 and extending ErrorHandler defined here :
and as per this error404 is defined as :
in your …./app/app_error.php you have defined it as
and in php such type of method overloading is not allowed. I think you have got your answer.
what you can do is that you can create your own function in your extended AppError class and then pass error name or template name in that like
and then on basis of different template names you can put conditions in _outputMessage() function and redirect user to different pages.