src/precore/util/Exceptions.php
public static function getCausalChain(Exception $exception) : ArrayObject
    {
        $result = new ArrayObject();
        while ($exception !== null) {
            $result[] = $exception;
            $exception = $exception->getPrevious();
        }
        return $result;
    }
public static function getCausalChain(Exception $exception) : ArrayObject
    {
        $result = new ArrayObject();
        while ($exception !== null) {
            $result[] = $exception;
            $exception = $exception->getPrevious();
        }
        return $result;
    }
Gets an {@link Exception} cause chain as an {@link ArrayObject}.
The first entry in the list will be $exception followed by its cause hierarchy.

@param Exception $exception
@return ArrayObject