Re: Re: ErrorStack problems
| From: | Dan Rossi | Date: | Fri, 01 Apr 2005 05:03:43 +0000 |
| Subject: | Re: Re: ErrorStack problems | ||
| References: | 1 2 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-18459@lists.php.net to get a copy of this message | ||
On 01/04/2005, at 2:29 PM, Greg Beaver wrote:
I have made that change its still displaying Pear_Error as the package name not MB2 is that due to the Pear_Error callback method being changed ? I do however get the message being displayed, $err['code'] however returns nothing. With that example I am using, should I be doing something with displaying the error in the ErrorStack callback method directly it looks like its pushing the error back into the ErrorStack again for some odd reason ? It seems alot of work just for setting up a global error handler :|class Error_Exceptions {getDebugInfo());var $_stack; function Error_Exceptions() { $this->_stack = &PEAR_ErrorStack::singleton('Project'); } function errorStack($error){ PEAR_ErrorStack::staticPush('PEAR_Error',null,'error', array('olderror'=>$error),$error->getMessage().\n.$error-}change this to case 'PEAR_Error':function errorCallback($err) { switch($err['package']){ case 'Project': // tell the error stack to log the error only // it will not be pushed onto the stack return PEAR_ERRORSTACK_LOG; break; case 'MDB2':cut the next two lines, and instead use:// re-package these errors as a mypackage error fit // for enduser consumption $this->_stack->push(MYPACKAGE_ERROR_DBERROR, 'error', array('dbmessage' => $err['message'], 'dbcode' => $err['code'], 'We are having Connection problems, please' . 'try again in a few moments'), '', $err); // include the error as re-packaged // tell the internal DB error stack to ignore thiserror,// as if it never happened return PEAR_ERRORSTACK_IGNORE; break; } // switch }} $myobj = &new Error_Exceptions; PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, array('Error_Exceptions', 'errorStack'));$dbstack = &PEAR_ErrorStack::singleton('MDB2'); $dbstack->setDefaultCallback(array(&$myobj, 'errorCallback'));PEAR_ErrorStack::setDefaultCallback(array(&$myobj, 'errorCallback');