From: mattsch at gmail dot com Operating system: Gentoo PHP version: 5.3.20 Package: PDO related Bug Type: Bug Bug description:PDO construct breaks exception chain
Description: ------------ The pdo construct has no way of continuing the exception chain. It needs another parameter at the end so you can pass in the previous exception. For that matter, is there any kind of effort to add exception chaining parameters for all php classes that throw exceptions? Test script: --------------- <?php class MyCustomException extends Exception {} function doStuff() { try { throw new InvalidArgumentException("You are doing it wrong!", 112); } catch(Exception $e) { try { $pdo = new PDO('foo', 'foo', 'bar', array()); // exception chain lost // $pdo = new PDO('foo', 'foo', 'bar', array(), $e); // needs additional previous exception parameter } catch (Exception $ex) { throw new MyCustomException("Something happened", 911, $ex); } } } try { doStuff(); } catch(Exception $e) { do { printf("%s:%d %s (%d) [%s]\n", $e->getFile(), $e->getLine(), $e->getMessage(), $e->getCode(), get_class($e)); } while($e = $e->getPrevious()); } Expected result: ---------------- foo.php:13 Something happened (911) [MyCustomException] foo.php:10 invalid data source name (0) [PDOException] foo.php:7 You are doing it wrong! (112) [InvalidArgumentException] Actual result: -------------- foo.php:13 Something happened (911) [MyCustomException] foo.php:10 invalid data source name (0) [PDOException] -- Edit bug report at https://bugs.php.net/bug.php?id=63868&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=63868&r=trysnapshot54 Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=63868&r=trysnapshot53 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=63868&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=63868&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=63868&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=63868&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=63868&r=needscript Try newer version: https://bugs.php.net/fix.php?id=63868&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=63868&r=support Expected behavior: https://bugs.php.net/fix.php?id=63868&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=63868&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=63868&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=63868&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=63868&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=63868&r=dst IIS Stability: https://bugs.php.net/fix.php?id=63868&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=63868&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=63868&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=63868&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=63868&r=mysqlcfg