Re: My Experience with PHP5 Error Handling (and possible
| From: | Lukas Smith | Date: | Wed, 25 Aug 2004 07:04:22 +0000 |
| Subject: | Re: My Experience with PHP5 Error Handling (and possible | ||
| References: | 1 2 3 4 5 6 | Groups: | php.pear.dev php.pear.dev |
| Request: | Send a blank email to pear-dev+get-32937@lists.php.net to get a copy of this message | ||
Alexey Borzov wrote:
Hi, This time really to the list... Greg Beaver wrote:I agree with Alexey here. Unless someone comes up with a solution that makes it painless to use Exceptions for the things they make sense in PHP5 we have a problem. I dont think it makes sense to make Exceptions painful to use just to get compatibility with PHP4. Sometimes you have to move on. To me the issue really lies with when to use Exceptions and when not to use Exceptions and this is the point where I disagree with the RFC. Not being able to connect to a database seems like a good case for an Exception in my eyes. Getting a contraint violation on a query isnt. Because the query was send and the database send a reply. Where is the exceptional state that warrents forcing me to wrap a try/catch block to handle this "error" .. potentially even multiple catch blocks. regards, LukasYes, and I see 2 possible solutions here: 1) Use PEAR_Error for php4 error reporting and exceptions for php5, don't mix; 2) Add cruft to make PEAR_Errors and exceptions *look* the same. In solution (2) developers will have to add cruft and users will have to learn cruft, in solution (1) --- no. Which is painless then?Let's look from a different angle: enforcing a PEAR_Error-like abomination will not add additional incentive for writing such php5 packages. The packages *will* undoubtedly appear, only the "BC-keeping" solution will leave us with either 2 transitional periods 1) transition from pure php4 to "backwards compatibility" (tm) 2) transition from "backwards compatibility" to pure php5 instead of one *or* useless cruft on all the packages for the foreseeable future. And PEAR which is now rightfully mocked for PEAR_Error will be mocked for whatever sh*t it will accept in place of it.Obvious problem #1: "People will be forced to use php4 and php5 packages at the same time until there are enough php5-only options to fill that gap. How can we make this as painless for both developers and users as possible?"