Throwable::getPrevious

(PHP 7, PHP 8)

Throwable::getPreviousReturns the previous Throwable

Descrierea

abstract public Throwable::getPrevious ( ) : Throwable

Returns any previous Throwable (for example, one provided as the third parameter to Exception::__construct()).

Parametri

Această funcție nu are parametri.

Valorile întoarse

Returns the previous Throwable if available, or null otherwise.

A se vedea și

add a note add a note

User Contributed Notes 1 note

up
0
harry at upmind dot com
5 years ago
/**
     * Gets sequential array of all previously-chained errors
     *
     * @param Throwable $error
     *
     * @return Throwable[]
     */
    function getChain(Throwable $error) : array
    {
        $chain = [];

        do {
            $chain[] = $error;
        } while ($error = $error->getPrevious());

        return $chain;
    }
To Top