Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.10.16

Request #7912 PEAR_Exception detect PEAR_Error as $message in __construct()
Submitted: 2006-06-15 21:58 UTC
From: jstump Assigned: cellog
Status: Closed Package: PEAR (version 1.4.9)
PHP Version: Irrelevant OS: Irrelevant
Roadmaps: (Not assigned)    
Subscription  


 [2006-06-15 21:58 UTC] jstump (Joe Stump)
Description: ------------ It'd be pretty nice for backwards compatibility with the thousands of lines of my code that use PEAR_Error to pass a PEAR_Error object to an Exception: $result = $db->query('A bad query!'); if (PEAR::isError($result)) { throw new PEAR_Exception($result); } I've attached a simple patch to suck in message and code. Someone with more PEAR internals experience might be able to further integrate the two. It'd also be useful to be able to pass PEAR_Exceptions to PEAR::raiseError(). Test script: --------------- --- /usr/local/lib/php/PEAR/Exception.php 2006-02-07 13:07:59.000000000 -0800 +++ /tmp/foo 2006-06-15 14:47:13.000000000 -0700 @@ -131,6 +131,9 @@ $p2 = array($p2); } $this->cause = $p2; + } elseif (PEAR::isError($message)) { + $code = $message->getCode(); + $message = $message->getMessage(); } else { $code = null; $this->cause = null;

Comments

 [2006-09-18 16:44 UTC] cellog (Greg Beaver)
This bug has been fixed in CVS. If this was a documentation problem, the fix will appear on pear.php.net by the end of next Sunday (CET). If this was a problem with the pear.php.net website, the change should be live shortly. Otherwise, the fix will appear in the package's next release. Thank you for the report and for helping us make PEAR better.