Re: exceptions
| From: | Tobias Schlitt | Date: | Sat, 08 May 2004 14:53:07 +0000 |
| Subject: | Re: exceptions | ||
| References: | 1 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-29011@lists.php.net to get a copy of this message | ||
Hi!
I just wanted to place my 2 cents about that topic here.
In general I have the feeling, that exceptions are a strong way of
flow-controll mechanism. Throw-Try-Catch is obviously a kind of controll
structure. For that I would agree with people saying, that Exceptions are a
way of conrolling program flow (as e.g. in Java).
In PHP we have a special case of the technique of exceptions. Since PHP is a
non-compiled (or better to say: a runtime compiled language) you have no
chance to see a uncaught exception before run-time or at least before the
exceptional state accours.
There are IMHO 2 ways to handle this speciallity:
a) Each and every throwen exception must be clearly documented besiden the
method can be throwen from (this includes exceptions throwen by method's
which are used by the class). If this rule is hold, we can use exceptions as
flow-controll.
b) Use exceptions only for the case of a fatal error. In this case every
posible exception should be documented as well, but since an error showen by
an excpetion is fatal, a documentation only can help the user to try
understanding the error.
The latter one is obviously the more logical one.
Regards,
Toby
--
Tobias Schlitt
a passion for php http://www.schlitt.info