References for error handling methods
| From: | Matthew J Gray | Date: | Fri, 11 May 2001 21:07:23 +0000 |
| Subject: | References for error handling methods | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-133@lists.php.net to get a copy of this message | ||
Hello.
I am a web applications programmer at a university
and I think DB part of pear is great. We may be
moving to other SQLs in the future and pear will
more than likely make that transition much
smoother...very cool.
Anyways...
I currently use error handling in a similar manner
as pear, at least the function callback aspect of
it. However, when I use methods of a class as the
error callback, it is useful for me to pass them
by reference because I have three different error
modes for handling an error based on the app's
production environment. When a method is
performed on a referneced object, the current
properties of the class(i.e. the error mode) are
used rather than the defaults.
The problem that I am encountering is that I
cannot have my callback in pear be a referenced
object and hence the default value is used as the
error mode rather than a user defined value.
consider the following:
<?php
class Test {
var $mode =
"DEFAULT";
function SetMode() {
$this->mode = "CHANGED";
}
function ErrorCallback() {
echo $this->mode . "<br>";
}
}
$test = new Test();
$test->SetMode();
$options = array( $test, "ErrorCallback" );
$pear_db->setErrorHandling( PEAR_ERROR_CALLBACK,
$options );
?>
On error, the test class error function would
return "DEFAULT" and not "CHANGED". In essence,
another instance of the test object is being used
for callback --not the one given to
setErrorHandling. IMHO, that is greatly confusing
and not practical. I have considered modifying
PEAR.php, but messing with the $options array in
setErrorHandling() seems like it would be a sticky
endeavor.
Did I make sense? and if so do you agree/disagree?
Thank you for your time
Matthew J. Gray
University of Wisconsin River Falls
Information Technology Services
matthew.j.gray@uwrf.edu