Re: PEAR.php to PHP5

From: Date: Thu, 01 Jul 2004 19:15:36 +0000
Subject: Re: PEAR.php to PHP5
References: 1 2 3  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-31474@lists.php.net to get a copy of this message
Hans_L wrote:
Welcome back, Greg. Stirring up some old ghosts, I see :) Greg Beaver wrote:
This code is nice - and once php4 is completely forgotten, it would handle the issues PEAR_ErrorStack seeks to solve wonderfully.
PEAR_ErrorStack is a great package, but I see it as simply a different way of handling errors (I know that you can use it to throw Exceptions also, but not sure I see the advantage to doing Exceptions that way).
It centralizes all logging and message generation. This takes complexity out of the exception class, and avoids code duplication, which reduces the chances for errors. People will constantly re-invent the wheel to use other solutions. I can't tell you how many times I have seen errors like "missing file" that were printed. trigger_error() is often abused. We get errors reported in phpDocumentor occasionally because a template was modified and Smarty triggered an error that the user didn't realize was a smarty template error. The list goes on and on of dumb error handling solutions that people use because it's too hard to re-invent the wheel properly. trigger_error() has always been my worst nightmare for debugging.
What do you mean by context generation? I think that (and have been meaning to provide diff) PEAR_Exception needs stack trace to show up in __toString() method, but this is a minor thing.
Everyone thinks the line number in the PHP file is the only context we need, but often it is simply irrelevant. The error condition rarely has to do with where it occurs in the PHP code. The location in a template, the socket connection, the database table, or spot in a query - these are the true context locations, not line 15 in foo.php.
Also, while getMessage() may be final there's nothing stopping you from changing the protected $message property. I do that on several exception subclasses I use. I want to use this package in Net_GeoIP as soon as it's considered "feature-complete". I don't see it as a curiosity at all. It adds some nice features to exceptions without inventing a new error handling scheme. I'm going to soon be releasing an alpha version of Net_GeoIP; if PEAR_Exception were ready (and available in PHP distrib) I'd use it today.
This is fine. I'm all for experimentation - just don't release a beta until there has been lots of time to experiment :) Greg

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