Re: last Pear.php.in and DB.php commit

From: Date: Tue, 17 Apr 2001 21:35:06 +0000
Subject: Re: last Pear.php.in and DB.php commit
References: 1 2 3  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-249@lists.php.net to get a copy of this message
["Tomas V.V.Cox" <cox@idecnet.com>] > > <?php > function handle_error ($obj) { > die ($obj->getMessage()); > } > PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, 'handle_error'); > $dsn = 'pgsql://postgres@localhostNONONO/no_db'; > $conn = DB::connect($dsn); > echo "no error"; > ?> > > The output of this is "no error". This is because, DB_extensions don't > use PEAR::raiseError (I think in all Pear clases errors should be raised > with this) and, because they have a default error_mode they'll never > notice that there are a global error mode (this is why I added the > GLOBAL stuff to PEAR_Error constructor, let's say a temporary fix). Also > I see that PEAR::setErrorHandling() do nothing (it simply set some > private vars?). I'm being completely senile. Yes, of course, DB_common doesn't inherit PEAR, so that's why. :-) It should though. > In your comment about PEAR::setErrorHandling vs $obj->setErrorHandling, > you are correct. I thinked that if DB, has its own DB::setErrorHandling > is no need for it, but I'm wrong. I think the correct > PEAR.php->setErrorHandling is: > > function setErrorHandling($mode, $options = null) > { > switch ($mode) { > .... // checks (sorry coding in Netscape is hard ;) > } > // something like if passed checks > if (isset($this)) { > $this->_default_error_mode = $setmode; > $this->_default_error_options = $setoptions; > $this->_default_error_callback = $setcallback; > } else { > $GLOBALS['_PEAR_default_error_mode'] = $setmode; > $GLOBALS['_PEAR_default_error_options'] = $setoptions; > $GLOBALS['_PEAR_default_error_callback'] = $setcallback; > } > } Take a look at the $set* variables again. They are references to the value that you really want to change later in the script. > And change the default error_mode property in common.php to > _default_error_mode (and of course the others). > > Other minor stuff: changed the PEAR_ERROR_CALLBACK checks with some IMHO > better checks like "function_exists" or "method_exists". Gotcha. I'll teaspoon your patch in tomorrow, I'm too tired right now. - Stig -- Stig Sæther Bakken <ssb@fast.no> Fast Search & Transfer ASA, Trondheim, Norway

« previous php.pear.dev (#249) next »