Re: error handling

From: Date: Thu, 13 Sep 2007 15:43:25 +0000
Subject: Re: error handling
References: 1 2 3  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-48016@lists.php.net to get a copy of this message
On 9/13/07, David Sanders <dsanders@baselinesolutions.com.au> wrote: > I think Bill is kind of raising a valid point here: What happens if your PEAR > package wants to "raise" a warning, deal with it, then continue on with its > regular routine? You can't raise an exception because that will jump out to the > closest catch right? Then the user can deal with the "PEAR_Warning" as they see > fit, printing it, logging it or ignoring it. No, that is what you use codes for. You can always catch an Exception and throw it again if it's not "critical". E.g.: (I assume this is inside a class and a constant ERR_CRIT is defined.) try { ... } catch (Services_Foobar_Exception $e) { if ($e->getCode() == SELF::ERR_CRIT) { throw $e; } // error is not critical - we carry on } No one prohibits you from using true/false for a simple status. Cheers, Till

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