Re: PEAR::setErrorHandling
| From: | Greg Beaver | Date: | Sun, 01 Aug 2004 18:18:14 +0000 |
| Subject: | Re: PEAR::setErrorHandling | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-13933@lists.php.net to get a copy of this message | ||
Hi,
There is no solution with existing code. What I would recommend is to copy the source of setErrorHandling() into a method in your extended object and simply set global error handling manually. There is no chance that BC will break in the future with regards to error handling because PEAR_Error is deprecated in favor of exceptions and pear_errorstack, and so no further development on PEAR_Error will occur.
Regards,
Greg
Fbm wrote:
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