Debug My Debugger
Posted: Wed Jun 15, 2005 4:02 am
Hello, I am recently making my own debugging functions,including sending myself an email indicating the details of errors occured when user viewed my page.
Notice that I can use the predefined constants, __FUNCTION__ and __FILE__, to point the current function and file where the error occured. However, if I will use this function repeatdly, I would also write the whole message format many times, including the predefined constants.
One solution I thought of is to get this message format inside ReportError() so that only the $ErrorCode will be passed.
But the problem is that the predefined constants will now point to ReportError() instead of DoStuff() function where the error occured.
Is there any way to tell ReportError() what function called him?
Code: Select all
// the function looks like this
function ReportError($msg){
ini_set('sendmail_from','user@mail.com');
mail('own@mail.com','Error Report!',$msg);
}
// and i call it this way in another script
funtion DoStuff(){
// some code ...
if($ErrorCode!=0){
$msg = "An ".getErrorMsg($ErrorCode)." error occured while calling ".__FUNCTION__." of ".__FILE__;
ReportError($msg)
}
}One solution I thought of is to get this message format inside ReportError() so that only the $ErrorCode will be passed.
Code: Select all
function ReportError($ErrorCode){
$details = "An ".getErrorMsg($ErrorCode)." error occured while calling ".__FUNCTION__." of ".__FILE__;
ini_set('sendmail_from','user@mail.com');
mail('own@mail.com','Error Report!',$details);
}Is there any way to tell ReportError() what function called him?