error handling again
| From: | Colin Viebrock | Date: | Thu, 08 Feb 2001 22:30:20 +0000 |
| Subject: | error handling again | ||
| Groups: | php.pear | ||
| Request: | Send a blank email to php-pear+get-1310@lists.php.net to get a copy of this message | ||
When somebody gets a second, could I get some closure on this
thread from last week? :)
Would the raise error stuff help me now?
- Colin
-----Original Message-----
From: Colin Viebrock [mailto:colin@easydns.com]
Sent: Thursday, February 01, 2001 3:11 PM
To: Stig S. Bakken
Cc: PHP-Pear
Subject: RE: [PHP-PEAR] error handling
> class myErrorClass extends PEAR_Error {
>
> function myErrorClass($code) {
> $mode = PEAR_ERROR_CALLBACK;
> $callback = "default_error_callback";
>
> if (in_array($code, $this->warn_errors)) {
> $callback = "error_callback";
> } else if (in_array($code, $this->fatal_errors)) {
> $callback = "fatal_error_callback";
> }
>
> $this->PEAR_Error('Some error', $code, $mode, $callback)
> }
> }
>
> (Your example returned a PEAR_Error object from its constructor rather
> than calling the inherited constructor, I've shown "the intended way" in
> the example above.)
Hmm ... this works well, except that for the "default_error_callback", I'd
like
my function to return the error object.
I tried changing your line back to
return $this->PEAR_Error('Some error', $code, $mode,
$callback);
And also set:
function default_error_callback($err) {
if (error_reporting() & E_NOTICE) {
echo "<br>\n";
printf("<b>Notice</b>: %s [%d]\n",
$err->message,
$err->code
);
}
return $err;
}
But that doesn't seem to do it (I admit that callbacks are confusing me a
wee bit).
If it makes it any clearer, I have myClass() and myErrorClass(). If myClass
generates
an error, it will invoke myErrorClass(). If the error was fatal, it should
say so and die.
If not, then it should just return the error object so the user's script can
proceed
accordingly.
Am I approaching this entirely wrong?
- Colin
--
PHP Extension and Add-on Repository (PEAR) mailing list.
Documentation can be found at http://pear.php.net/doc/pear.html
To unsubscribe, e-mail: php-pear-unsubscribe@lists.php.net from the
mail address you subscribed with.