Re: What do you think which mode will be standard for PEAR Error handling in PHP5?

From: Date: Wed, 03 Dec 2003 19:50:56 +0000
Subject: Re: What do you think which mode will be standard for PEAR Error handling in PHP5?
References: 1 2 3 4  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-9282@lists.php.net to get a copy of this message
Hi, I see no practical way to maintain BC with PEAR_Error in PHP 5 and use exceptions. Code will need to be rewritten absolutely everywhere. For this reason, I'd like to see a PHP5-only non-BC solution for using exceptions which will be used in PHP5+ packages. I've been thinking about some of the problems for months, and will be trying some stuff out soon, and posting ideas :). Practical input is welcome. Greg Jackson Miller wrote:
On Wednesday 03 December 2003 9:14, Michael Wallner wrote:
...so catch() replaces PEAR::isError()
Yeah, I get that part. But it seems to me that PEAR needs some kind of isError callback for all the code that is using PEAR modules. Within the modules it would all be try...catch, but take the following code as an example. While I don't think that we would need to worry about backward compatibility for the pear modules themselves, it might be a good idea to think about the users (though I could be biased on that one). <?php // include PEAR::DB require_once 'DB.php'; // connect to the database $myDb = DB::connect('pgsql://user:pass@host/database'); // check that the connection is valid if (DB::isError($myDb)) {
    die ($myDb->getMessage());
} // query the database $sql = "SELECT * FROM table WHERE col = 'value'"; $result = $myDb->query($sql); // check to see if the query worked if (DB::isError($result)) {
    // query failed
    $error = $result->getMessage();
} else { // process query results } ?> -Jackson


« previous php.pear.general (#9282) next »