Recorrer, e imprimir la traza de una excepción.
    
<?php
class MiPropiaExcepción extends Exception {}
function hacerCosas() {
    try {
        throw new InvalidArgumentException("¡Lo está haciendo mal!", 112);
    } catch(Exception $e) {
        throw new MiPropiaExcepción("Ocurrió algo", 911, $e);
    }
}
try {
    hacerCosas();
} 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());
}
?>
     
    Resultado del ejemplo anterior es similar a:
/home/bjori/ex.php:8 Ocurrió algo (911) [MiPropiaExcepción]
/home/bjori/ex.php:6 ¡Lo está haciendo mal! (112) [InvalidArgumentException]