Re: exceptions (was: how to mark protected properties?)

From: Date: Tue, 08 Jun 2004 07:08:58 +0000
Subject: Re: exceptions (was: how to mark protected properties?)
References: 1 2 3  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-30131@lists.php.net to get a copy of this message
<snip> Ucaught exceptions are fatal. This means that you are forced to deal with any exception. It can lead to huge exception blocks where previously you could focus on handling the errors you actually care for. Yes you might claim every error should be dealt with. Reality dictates otherwise and changing this just might diminish the adavantage PHP has. With PEAR_Error you have the choice to whip up a quick prototype. Over use of execeptions prevents this as it forces you to do error handling. Exceptions also enable very tricky goto style code flow handling. While some people claim its ok to use exceptions for code flow as long as they dont leak out of a defined self contained piece of code, but I strongly disagree. Any mistake in this misuse of exceptions will lead to a fatal error as the exception is likely to remain uncaught. In conclusion I see exceptions as a perfect example for previously fatal errors. However PEAR code was never supposed to hit those anyways, as long as the package is properly installed anyways. I can see exceptions in really specific cases like "connect()" for database packages as there you are not asking "can I connect" but rather "connect and retun a handle". So an error doing the connection would be an "execeptional" state. But I wouldnt say the same about a failed query due to a syntax error and I have a hard time explaining the difference to the "connect" example. regards, Lukas

« previous php.pear.dev (#30131) next »