Pear Error fun
| From: | Joseph Blythe | Date: | Mon, 16 Jun 2003 06:14:54 +0000 |
| Subject: | Pear Error fun | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-5981@lists.php.net to get a copy of this message | ||
Hello everyone,
Am just struggling with PEAR Error I am trying to implement an error
callback routine but I can not seem to make it work have read the tutourial
at:
http://www.php-mag.net/itr/online_artikel/psecom,id,330,nodeid,114.html
and
also the manual section on PEAR base and error handling class.
I just having trouble on the OOP side, an quick example what I have been
trying maybe someone point out a better way?
The below code is returning an object for some reason??
<?php
require_once("PEAR.php");
// Class foo
class foo extends PEAR
{
function foo()
{
$this->PEAR();
}
// Do some useful stuff
}
// Class Bar
define("FOOBAR_ERROR", 10);
class bar extends foo
{
var $errors = array(10 => "An ugly error has occured.");
function bar()
{
$this->setErrorHandling(PEAR_ERROR_CALLBACK, array("bar",
"handle_error"));
}
function error_test($my_error)
{
if ($my_error == 0) {
return $this->raiseError($this->errors[FOOBAR_ERROR],
FOOBAR_ERROR);
}
return true;
}
function handle_error($error)
{
print $error->getCode() . " " . $error->getMessage();
exit;
}
}
$bar = new bar();
print $bar->error_test(0);
?>
The reason I want 'foo' to extend PEAR not 'bar' is I want a core class
which all my others are derived from each having thier own set of error
codes ect...
Any pointers would be appreciated, especially if I am going about this
totally wrong, it wouldn't be the first time believe me :)
Regards,
Joseph