Re: trapping exception?

From: Date: Thu, 10 May 2001 12:11:26 +0000
Subject: Re: trapping exception?
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-127@lists.php.net to get a copy of this message
Steven Haryanto wrote: > > Is there a trick to trap PEAR_Error raised by outer function calls? > I have method a() which calls method b(). If method b() calls > raiseError, and I have set global errorHandling to PRINT, can I > suppress the error message caused by b() and just print the later > error raised by a() itself? > One idea is to return a Pear_error obj in b() instead of using raiseError. So: function a(){ if (PEAR::isError($err = $this->b()){ return $this->raiseError($err->getMessage()); } } function b(){ if ($not_valid){ return new Pear_Error ('b() failed'); } } Perhaps it's not a valid solution for you but it's an idea. Tomas V.V.Cox

« previous php.pear.general (#127) next »