Throwable::getPrevious

(PHP 7)

Throwable::getPreviousReturns the previous Throwable

설명

abstract public Throwable Throwable::getPrevious ( void )

Returns any previous Throwable (for example, one provided as the third parameter to Exception::__construct()).

인수

이 함수는 인수가 없습니다.

반환값

Returns the previous Throwable if available, or NULL otherwise.

참고

add a note 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