Re: Re: ErrorStack problems
| From: | Dan Rossi | Date: | Fri, 01 Apr 2005 08:16:49 +0000 |
| Subject: | Re: Re: ErrorStack problems | ||
| References: | 1 2 3 4 5 6 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-18464@lists.php.net to get a copy of this message | ||
Here is the error class as it stand, it still needs alot of work, but you can see where I might be trying to head with this, i still yet to add logging in, but i think i have to set that up somewhere else other than in the callback, and email error feature would also be cool in this case. I am using Flexy to display the errors in a templated look in the browser. The freaky thing about using pear classes in a callback function is that if there is an error it wont trap it hehe. I have soughta realised that what I am doing is incorrect becauses its suppose to stack the error, this is however doing exactly what pear error is doing :) So once the error is stakked, no idea what other place to use to output them.
class Error_Exceptions
{
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-
getDebugInfo());}
function errorCallback($err)
{
global $settings;
switch($err['package']) {
case 'PEAR_Error':
if ($settings['project']['debug']) {
$this->error_message = $err['message'];
$tpl = new HTML_Template_Flexy($settings['flexy']);
$tpl->compile('developer_errors.html');
die($tpl->outputObject($this));
} else {
if ($settings['project']['email_errors']) {
require_once 'Mail/QueueCustom.php';
$mail_queue = new
Mail_QueueCustom($settings['mail_queue']['db_options'],$settings['mail_queue']['mail_options']);
//$mail_queue->sendAsHTML(true);
$mail_queue-setSender($settings['project']['admin_name'],$settings['project']['admin_email']);$mail_queue-
setRcpt($settings['project']['admin_name'],$settings['project']['admin_email']);$mail_queue->setSubject(Errors Found With the system); $mail_queue->sendMailNow($err['message']);
}$tpl = new HTML_Template_Flexy($settings['flexy']); $tpl->compile('errors.html'); die($tpl->outputObject($this));
}
return PEAR_ERRORSTACK_IGNORE;
break;
/*
case 'Project':
die();
// tell the error stack to log the error only
// it will not be pushed onto the stack
return PEAR_ERRORSTACK_LOG;
break;
case 'MDB2':
die(yes);
// 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 this
error,
// as if it never happened
return PEAR_ERRORSTACK_IGNORE;
break;
*/
} // switch
}
}