PEAR_Error class
| From: | cagrET | Date: | Sun, 25 May 2003 22:21:48 +0000 |
| Subject: | PEAR_Error class | ||
| Groups: | php.pear.dev | ||
| Request: | Send a blank email to pear-dev+get-16691@lists.php.net to get a copy of this message | ||
Hi,
about PEAR Error handling
I have own DB class and DB_Error class which extends PEAR_Error
1. I need to display db errors in my own style
so i need to use PEAR_ERROR_CALLBACK and create
next object DB_Error_Callback
2. But i need also errors to be logged by my
Error class (into database,file,mail or xml)
and i cant use PEAR_ERROR_CALLBACK cause i used
it already in DB_Error
I see 2 solutions:
1.
If there was in PEAR_Error method called
printError() - class extending PEAR_Error
could overwrite this method and have own display style
so in PEAR_Error Constructor it could be:
if ($mode & PEAR_ERROR_PRINT) $this->printError()
if ($mode & PEAR_ERROR_DIE) $this->printError(); DIE();
and
printError($message) {
printf(%s);
}
or smth like that
2.
another solution
If i could use more than 1 callback in error handling
smth like this
$options = array(
array(&$object1, 'method'),
array(&$object2, 'method')
);
--
With pear_error i had an another problem
I cant use PEAR_ERROR_CALLBACK & PEAR_ERROR_TRIGGER with E_USER_ERROR
maybe smth like this could help
$GLOBALS['_PEAR_default_error_options'] = array(
'callback' => array(&$object, 'method'),
'trigger' => E_USER_ERROR
);
instead of
$GLOBALS['_PEAR_default_error_options'] = array(&$object, 'method');
and adding more than 1 callback could be usefull too :)
Is any of this changes possible ?
cheers,
--
cagrET