Re: exceptions
| From: | Hans Lellelid | Date: | Tue, 08 Jun 2004 19:15:07 +0000 |
| Subject: | Re: exceptions | ||
| References: | 1 2 3 4 5 6 7 8 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-30207@lists.php.net to get a copy of this message | ||
Hi Greg,
Good message, though I didn't like the parts where you disagreed with me :)
Greg Beaver wrote:
Exceptions will never remove the need for code that logs and handles unusual output, let's get that straight right now. Even if you only use exceptions, if you wish to do any advanced logging, you must either call a logging method in *every* catch() block:<salute>yessir!</salute> :) But yes, you are right; Exceptions provide an elegant solution to the flow-control of error handling, but not to the logging, or other auxiliary actions. One clarification, though. Generally, in apps I've developed (and in all other complex apps whose source I've studied), there are relatively few top-level catch blocks where errors are actually logged. Errors thrown within the program may be caught & re-thrown (or wrapped) in many cases, but logging happens at the top. So you don't actually need to log in every catch() block, just every top-level catch() block. This difference makes explicit logging not that big a deal in actuality.
Let's stop quibbling about either/or - there's no point. Programming will ALWAYS need both solutions. As there is nothing satisfactory built into the language (yet?), packages like PEAR_ErrorStack will fill that void until PHP does.Quibbling!?! "Quod usque tandem abutere Catalina patentia nostra ... " It's that level of greatness! :) On the other hand, great work with PEAR_ErrorStack. You've clearly done a lot of thinking about this stuff. Hans