CakeFest 2024: The Official CakePHP Conference

Throwable::getPrevious

(PHP 7, PHP 8)

Throwable::getPreviousRetorna o Throwable anterior

Descrição

public Throwable::getPrevious(): ?Throwable

Retorna qualquer Throwable anterior (por exemplo, aquele fornecido como o terceiro parâmetro para Exception::__construct()).

Parâmetros

Esta função não possui parâmetros.

Valor Retornado

Retorna o Throwable anterior se disponível, ou null caso contrário.

Veja Também

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