Re: Try Catch

From: Date: Sat, 21 Jul 2001 18:02:46 +0000
Subject: Re: Try Catch
References: 1 2 3 4 5  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-913@lists.php.net to get a copy of this message
Oleg Rekutin wrote: > > cox@idecnet.com (Tomas V.V.Cox) wrote in > news:3B5973E6.40F825ED@idecnet.com: > > > Oleg Rekutin wrote: > >> > > Well, this doesn't solve the problem (problem w/ callbacks), Sure, doesn't solve the callback problem. To use callbacks you should do: // change handler PEAR::setErrorHandling(PEAR_ERROR_RETURN); if (DB::isError($id = $db->nextID())) { ... } // restore handler PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, '..'); >it avoids it > and just coats the original issue in a different kind of sugar. :) Your > try/mydie is basically a shorter way of writing > > $result = expr; > if (DB::isError($result)) { die(...getmessage..etc...); } Not only basically, also solves the problem as it don't use the native raiseError(). > > > Perhaps the best solution could be to provide a system whithin all DB > > functions that use internal DB functions don't use the global error > > handler and treat the error by them selves. But I think that only very > > few functions are affected by this problem (only nextID/createSequence > > ?). > > That should be the case, I think. I would consider the current callback- > related problem with nextID/createSequence a bug. > Me too, but createSequence() is marked as public so it need to use raiseError to be consistent also nextID() use $this->query() function that also use raiseError. The solution involves 1) change createS..() and nextID() to do native queries or 2) change the handler in nextID() to PEAR_ERROR_RETURN and restore it when finish. Other ideas? Tomas V.V.Cox

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