downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

Exception::getCode> <Exception::getMessage
Last updated: Fri, 14 Aug 2009

view this page in

Exception::getPrevious

(PHP 5 >= 5.3.0)

Exception::getPreviousRetourne l'exception précédente

Description

final public Exception Exception::getPrevious ( void )

Retourne l'exception précédente (le troisième paramètre de la méthode Exception::__construct).

Liste de paramètres

Cette fonction ne contient aucun paramètre.

Valeurs de retour

Retourne la précédente Exception si disponible, NULL sinon.

Exemples

Exemple #1 Exemple avec Exception::getPrevious

Une boucle, on affiche et on capture les exceptions.

<?php
class MyCustomException extends Exception {}

function 
doStuff() {
    try {
        throw new 
InvalidArgumentException("Vous avez fais une erreur !"112);
    } catch(
Exception $e) {
        throw new 
MyCustomException("Un problème est survenu"911$e);
    }
}


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());
}
?>

L'exemple ci-dessus va afficher quelque chose de similaire à :

/home/bjori/ex.php:8 Un problème est survenu (911) [MyCustomException]
/home/bjori/ex.php:6 Vous avez fais une erreur ! (112) [InvalidArgumentException]



add a note add a note User Contributed Notes
Exception::getPrevious
There are no user contributed notes for this page.

Exception::getCode> <Exception::getMessage
Last updated: Fri, 14 Aug 2009
 
 
show source | credits | sitemap | contact | advertising | mirror sites