From:             mattsch at gmail dot com
Operating system: Gentoo
PHP version:      5.3.20
Package:          Class/Object related
Bug Type:         Feature/Change Request
Bug description:Implement exception chaining within core classes

Description:
------------
php core classes have no way of continuing the exception chain.  If we are
to have proper exception chaining as implemented in the exception class in
php 5.3, we should also have the ability to continue the exception chain
within php core classes to make debugging easier.

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:
----------------
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:
--------------
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=63873&edit=1
-- 
Try a snapshot (PHP 5.4):   
https://bugs.php.net/fix.php?id=63873&r=trysnapshot54
Try a snapshot (PHP 5.3):   
https://bugs.php.net/fix.php?id=63873&r=trysnapshot53
Try a snapshot (trunk):     
https://bugs.php.net/fix.php?id=63873&r=trysnapshottrunk
Fixed in SVN:               https://bugs.php.net/fix.php?id=63873&r=fixed
Fixed in release:           https://bugs.php.net/fix.php?id=63873&r=alreadyfixed
Need backtrace:             https://bugs.php.net/fix.php?id=63873&r=needtrace
Need Reproduce Script:      https://bugs.php.net/fix.php?id=63873&r=needscript
Try newer version:          https://bugs.php.net/fix.php?id=63873&r=oldversion
Not developer issue:        https://bugs.php.net/fix.php?id=63873&r=support
Expected behavior:          https://bugs.php.net/fix.php?id=63873&r=notwrong
Not enough info:            
https://bugs.php.net/fix.php?id=63873&r=notenoughinfo
Submitted twice:            
https://bugs.php.net/fix.php?id=63873&r=submittedtwice
register_globals:           https://bugs.php.net/fix.php?id=63873&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=63873&r=php4
Daylight Savings:           https://bugs.php.net/fix.php?id=63873&r=dst
IIS Stability:              https://bugs.php.net/fix.php?id=63873&r=isapi
Install GNU Sed:            https://bugs.php.net/fix.php?id=63873&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=63873&r=float
No Zend Extensions:         https://bugs.php.net/fix.php?id=63873&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=63873&r=mysqlcfg

Reply via email to