Throwable::getPrevious

(PHP 7, PHP 8)

Throwable::getPreviousDevuelve el objeto Throwable previo

Descripción

public Throwable::getPrevious(): ?Throwable

Devuelve el objeto Throwable previo (por ejemplo, uno proporcionado como tercer parámetro de Exception::__construct()).

Parámetros

Esta función no tiene parámetros.

Valores devueltos

Devuelve el objeto Throwable anterior si está disponible, o null si no lo está.

Ver también

add a note

User Contributed Notes 1 note

up
0
harry at upmind dot com
6 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