Re: Exception misinformation
| From: | Michael Wallner | Date: | Wed, 07 Jul 2004 09:06:54 +0000 |
| Subject: | Re: Exception misinformation | ||
| References: | 1 2 3 4 5 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-31702@lists.php.net to get a copy of this message | ||
Hi Lukas Smith, you wrote:
> Justin Patrin wrote:
>
>> I still wonder about this, though, as many experienced coders say
>> that Exceptions shouldn't be used for code flow handling.
>
>
> Using exceptions means using exceptions as a straight forward goto.
Well, I hope Wez stands up and implements finally {}
in future PHP5.
> For example you call a method login() which checks the credentials of
> the user. Now you could throw an exception if the user is not logged
> in to send him to a different part of your code. Hmm maybe someone
> else can come up with an even clearer example. But a login method not
> being able to log someone in is usually not an error and certainly
> not an exception thing.
It's already a good example. It should return false and a
yet to be invented (or ported) warning mechanism should issue
a warning what happened.
To be clear: I'm all for using Exceptions as errors, as they
eliminate the need to invent a error handling as PEAR_Error did
in the past, but it's simply true that they don't solve the
warning/notice problem PHP is still suffering from.
But hey - to be honest - PHP is a mess, and we always try to
clean up this mess a little bit, so why don't we try to
provide a solution for this problem instead of bashing
Exceptions in several miles long threads.
I wonder if we (PEAR-dev) are already at a point - we
though should be for sure - to talk about the solution
not about the eligibility of Exceptions (if someone is
in doubt, he should look at other languages, if he never
did).
And - yes, it will be a compromise probably not
satisfying 100% of each party.
Regards,
--
Michael - < mike(@)php.net >
Attachment: [application/pgp-signature] OpenPGP digital signature signature.asc
Attachment: [application/pgp-signature] OpenPGP digital signature signature.asc