> I'd like to handle major (and plugin-specific) errors that may happen
> with thecakeErrormethod, but we can't define a MyPluginAppError? Is
> there another way?
You can achieve this in the following way:
1. In your {Plugin}AppController override the cakeError() method with
the following code:
function cakeError($method, $messages = array()) {
if (!class_exists('ErrorHandler')) {
App::import('Core', 'Error');
$path = APP . 'plugins' . DS .
Inflector::underscore($this-
>plugin) . DS;
if (file_exists($path . 'error.php')) {
include_once ($path . 'error.php');
} elseif (file_exists($path . 'app_error.php')) {
include_once ($path . 'app_error.php');
}
}
return parent::cakeError($method, $messages);
}
2. In your plugin's AppError class, override the __outputMessage()
method as follows:
function __outputMessage($template) {
$this->controller->viewPath = '..' . DS . 'plugins' . DS .
basename(dirname(__FILE__)) . DS . 'views' . DS . 'errors';
parent::__outputMessage($template);
}
That's all.
The second point goes agains the "__" private method convention. If
you don't want to violate this rule, just add the "$this->controller-
>viewPath ..." row at the beginning of all your custom error methods.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---