Re: PEAR_Error, ErrorStack, Exception, and compatibility
| From: | David Costa | Date: | Tue, 22 Jun 2004 20:53:44 +0000 |
| Subject: | Re: PEAR_Error, ErrorStack, Exception, and compatibility | ||
| References: | 1 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-31125@lists.php.net to get a copy of this message | ||
On Jun 22, 2004, at 10:47 PM, Justin Patrin wrote:
I think this discussion may have been lost in the multitude of messages in other threads, so I'm starting a new thread. There has been lots of talk about Exceptions in PEAR. Many people are saying that PHP5 PEAR classes should not use PEAR_Error at all and only throw exceptions.you can't use PEAR_Error. You can't include PEAR. THis because PHP 5 only PEAR packages should work on E_STRICT.... Thomas was kind enough to do a PEAR exceptions class for error handling see http://cvs.php.net/co.php/php-src/pear/PEAR/Exception.php?r=1.1
This can cause many problems: 1) The code is not compatible with PHP4E_STRICT PHP 5 code, as it was suggested by Lukas and others as a requirement for PHP 5 packages, will never work with PHP 4 includes
2) Some people believe that Exceptions are supposed to be for Exceptional circumstances, not general error handlingYes I was one of them. Then I spent some time listening to Hans and others and here am I. It doesn't really matter what we believe but what PHP 5 is.
3) As per 2), it forces the user to handle errors in a certain way. For this reason, I propose the following: Backwards compatibility would be very simple by simply allowing a mechanism (through PEAR_Error/Stack) to throw the error as an exception or return a PEAR error. Here's what would happen.You can't
Package1 likes PEAR_Errors. It sets (pushes) the error mode to PEAR_ERROR_RETURN. It uses an instance of Package3 which then has an error. Package3 makes a call as such:you can't, $var is deprecated Justin, please don't take this the wrong way but you should really take some time to try PHP 5 and understand the differences and why you can't do a PHP 5 package to work on PHP 4 nor include PHP 4 packages. In short there is no PHP 5 class compatible with PHP 4. If you wish a free PHP 5 hosting I would be able to help, for testing or anything you need.
Cheers David Costa