Throwable::getPrevious
(PHP 7, PHP 8)
Throwable::getPrevious — 返回先前的 Throwable
参数
此函数没有参数。
返回值
如果有的话,返回先前的 Throwable,否则就返回 null
。

User Contributed Notes 1 note
harry at upmind dot com ¶
3 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;
}
备份地址:http://www.lvesu.com/blog/php/throwable.getprevious.php