/** * Return Error throwable trace in array format. * * @param \Error|\Exception $ex * @return string[] */ public static function toThrowableTrace($ex) { $list = []; for ($stack = Throwable::getThrowableStack($ex); $stack !== null; $stack = $stack['prev']) { $list[] = Throwable::parseThrowableMessage($stack); } return array_reverse($list); }