Re: Should return "TRUE or PEAR_Error" ???
| From: | Philippe Jausions | Date: | Mon, 20 Jul 2009 22:06:25 +0000 |
| Subject: | Re: Should return "TRUE or PEAR_Error" ??? | ||
| References: | 1 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-52428@lists.php.net to get a copy of this message | ||
miya@theta.ne.jp wrote:
> I 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.
> Is there the one like some guidelines?
> (e.g. naming for method and other)
>
> Thanks
> Sorry, if I mistake English.
>
> ----
> Takayuki Miyauchi
> Osaka, Japan