Re: Should return "TRUE or PEAR_Error" ???
| From: | Joe Stump | Date: | Mon, 20 Jul 2009 22:43:07 +0000 |
| Subject: | Re: Should return "TRUE or PEAR_Error" ??? | ||
| References: | 1 2 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-52429@lists.php.net to get a copy of this message | ||
On Jul 20, 2009, at 11:06 PM, Philippe Jausions wrote:
miya@theta.ne.jp wrote:To expound on this a bit more, PEAR_Error is deprecated in favor of exceptions. Your package: 1. Must be PHP5 2. Must use exceptions That being said, Philippe is correct that a simple true/false is perfectly fine as well. --JoeI am developping "Mail_CheckUser" package. http://pear.php.net/pepr/pepr-proposal-show.php?id=605 A lot of methods of Net_SMTP package return "TRUE or PEAR_Error". But, I thinks it is confusing for me. (I actually misunderstood it. ) However, I think that I should do Mail_CheckUser so if a lot of packages are so. Now, it return "TRUE OR FALSE", and can access PEAR_Error object with getError() method. Mail_checkuser should return "TRUE OR PEAR_Error" or "TRUE OR FALSE"?It would make more sense to keep a TRUE / FALSE return value and throw a PEAR_Exception($error) when your code gets a PEAR_Error internally. This means TRUE and FALSE are expected values when calling the method. If a problem occurred and a TRUE or FALSE cannot be safely determined, then it's an exceptional situation.