Error::getPrevious

(No version information available, might only be in Git)

Error::getPreviousZwraca poprzedni Throwable

Opis

final public Error::getPrevious ( void ) : Throwable

Zwraca poprzedni Throwable (trzeci parametr Error::__construct()).

Parametry

Ta funkcja nie posiada parametrów.

Zwracane wartości

Zwraca poprzedni Throwable lub NULL jeśli nie jest dostępny.

Przykłady

Przykład #1 Przykład użycia Error::getPrevious()

Wyświetlanie śladu błędu za pomocą pętli.

<?php
class MyCustomError extends Error {}

function 
doStuff() {
    try {
        throw new 
InvalidArgumentError("Robisz to źle!"112);
    } catch(
Error $e) {
        throw new 
MyCustomError("Coś się stało"911$e);
    }
}


try {
    
doStuff();
} catch(
Error $e) {
    do {
        
printf("%s:%d %s (%d) [%s]\n"$e->getFile(), $e->getLine(), $e->getMessage(), $e->getCode(), get_class($e));
    } while(
$e $e->getPrevious());
}
?>

Powyższy przykład wyświetli coś podobnego do:

/home/bjori/ex.php:8 Coś się stało (911) [MyCustomError]
/home/bjori/ex.php:6 Robisz to źle! (112) [InvalidArgumentError]

Zobacz też:

add a note add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top