Re: Exception misinformation
| From: | Sergio Carvalho | Date: | Thu, 08 Jul 2004 14:56:36 +0000 |
| Subject: | Re: Exception misinformation | ||
| References: | 1 2 3 4 5 6 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-31752@lists.php.net to get a copy of this message | ||
Lukas Smith wrote:
Here is one of the exceptions threads in internals@: http://marc.theaimsgroup.com/?l=php-dev&m=108173999125340&w=2 Not sure if this thread is going to move us forward at all, because each camp will find exactly their argument again and still dont see the others. I tried to summarize the issue at hand before but I will give it another try. Atleast part of the issue is the following question: Should errors be fatal if they are not handled or not? A mistake in your conf array will likely mean things will not work as planned. While being able to know that something went wrong is obviously important, the question is when the error is not handled should this be a fatal error or not?Unhandled errors should be fatal. They should also be considered a bug. I'll try to explain my reasoning using your example. Your example is quite a good one, because it's a minor error, and the app could probably work even with an error in the conf array. If the error is a minor one, and you, the developer, know it is minor, you should explicitely say this in the code. Catch the exception, and ignore it (comment the code, log the warning -- the usual -- but don't halt the app). If you don't explicitely say the error is minor, then the error handling engine -- exceptions in this case -- should assume the worst, and halt the app. I agree that exceptions are sometimes a pain in the arse, because they force explicit handling of all errors. This is somewhat strange on a scripting language, and here's where I think PHP developers have a reason to shun exceptions. However, PEAR is a bunch of libraries. Libraries should be more solid than simple scripts, and exceptions are a must. Cheers, Sérgio Carvalho