note 19521 added to function.set-error-handler
| From: | ned at wgtech dot com | Date: | Fri, 01 Mar 2002 16:52:41 +0000 |
| Subject: | note 19521 added to function.set-error-handler | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-27235@lists.php.net to get a copy of this message | ||
Just spent two days trying to find some method where a class can handle errors thrown at my
convienience. After fighting with the pitfalls of this problem this is what I came up with. Hope it
helps someone else save a little time. Its nice because all instances of this class will point to
the same array that stores the errors.
class ApplicationObject {
var $error_List;
function ApplicationObject() {
set_error_handler('trapError');
$this->error_List = &trapError();
}
}
function &trapError() {
static $error_Vals = array();
if (func_num_args()==5) { // Error Event has been passed
$error_Vals[] = array( 'err_no' => func_get_arg(0), 'err_text' =>
func_get_arg(1), 'err_file' => func_get_arg(2), 'err_line' =>
func_get_arg(3), 'err_vars'=>func_get_arg(4));
}
if (func_num_args()==0) { // Setup call. Return reference
return $error_Vals;
}
}
--
http://www.php.net/manual/en/function.set-error-handler.php
http://master.php.net/manage/user-notes.php?action=edit+19521
http://master.php.net/manage/user-notes.php?action=delete+19521
http://master.php.net/manage/user-notes.php?action=reject+19521