It extends the class and by that AppError inherits all the methods from ErrorHandler.So if you don't have a method error404() , the AppError object will call its parent method, in this case error404 in ErrorHandler;
However, if you define the method that already exits in ErrorHandler it will not 'extend it' but 'override it.'
In other words: If you create method error404 and this method is called by AppError object it will call its version of error404()
Now, if you look at error404 function inside ErrorHandler
function error404($params) {
extract($params);
if (!isset($url)) {
$url = $action;
}
if (!isset($message)) {
$message = '';
}
if (!isset($base)) {
$base = '';
}
header("HTTP/1.0 404 Not Found");
$this->error(array('code' => '404',
'name' => 'Not found',
'message' => sprintf("The requested address %s was not found on this server.", $url, $message),
'base' => $base));
exit();
}
you can see that there is certain behavior and params are expected in this function. So that's why your app is crashing, somewhere AppError is calling error404 expecting the behavior from parent (ErrorHandler) class.Try to mimic the method (by including params and exit at the end).
Also $this->set('title_for_layout', 'Not Found (404)');
I think it should be
$this->controller->set('title_for_layout', 'Not Found (404)');`