PEAR::setErrorHandling
| From: | fbm | Date: | Sat, 31 Jul 2004 21:37:47 +0000 |
| Subject: | PEAR::setErrorHandling | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-13930@lists.php.net to get a copy of this message | ||
Hi everybody,
I have a problem with setErrorHandling. I wish to switch error handler while
executing a piece of code.
So I wrote something like :
class test extends PEAR {
function init() {
PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, 'temp_error_handler');
$this->mymethod (); // mymethod is executing some parsing,etc;..
PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, 'error_handler');
}
}
==> And the error handler is set to $this instead of been set as global ???
If you look at the beginning of the PEAR::setErrorHandling method you read :
if (isset($this) && is_a($this, 'PEAR')) {
$setmode = &$this->_default_error_mode;
$setoptions = &$this->_default_error_options;
} else {
$setmode = &$GLOBALS['_PEAR_default_error_mode'];
$setoptions = &$GLOBALS['_PEAR_default_error_options'];
}
....
This means that if you call PEAR::setErrorHandling within an object, the
error handler is assigned to the current object rather that to the global
handler.
How can I switch the global ErrorHandler within a object method ?
Is it the way it is supposed to work ?
thanks for your help
fbm