Re: Re: PEAR's Error Handling and PHP5
| From: | Lukas Smith | Date: | Wed, 21 Jun 2006 06:35:37 +0000 |
| Subject: | Re: Re: PEAR's Error Handling and PHP5 | ||
| References: | 1 2 3 4 5 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-43053@lists.php.net to get a copy of this message | ||
Justin Patrin wrote:
This reminds me of another reason I like Exceptions over PEAR_Error returns. It separates error handling from normal return values. There is no need to check return values as an error will throw an exception instead of returning an object which won't have the correct properties for code to continue.this is what PEAR_ErrorStack brought to the table, though the problem there is obviously how to deal with expected boolean return values where you can also get an error condition.
I would also like to point out the Exception discussion and guidelines on the wiki outline that as long as a function is expected to return a status that it need not throw an exception. In other words, if a failure is an expected outcome of a function call, it is not an error condition. (Of course, the caller would probably upgrade this to an error condition, but I digress.)anyways the point was: if we add support for this (which means adding an isInstanceOf() method to all classes) then the choice is in the hands of the user. if we dont then it isnt unless we stick with PEAR_Error. remember we can throw execeptions from a PEAR_Error callback and not the other way around. regards, Lukas