protected function convertExceptionToArray($exception)
    {
        if (!Reaction::isDebug() && !$exception instanceof UserException && !$exception instanceof HttpException) {
            $exception = new HttpException(500, Reaction::t('rct', 'An internal server error occurred.'));
        }

        $array = [
            'name' => ($exception instanceof Exception || $exception instanceof ErrorException) ? $exception->getName() : 'Exception',
            'message' => $exception->getMessage(),
            'code' => $exception->getCode(),
        ];
        if ($exception instanceof HttpException) {
            $array['status'] = $exception->statusCode;
        }
        if (Reaction::isDebug()) {
            $array['type'] = get_class($exception);
            if (!$exception instanceof UserException) {
                $array['file'] = $exception->getFile();
                $array['line'] = $exception->getLine();
                $array['stack-trace'] = explode("\n", $exception->getTraceAsString());
            }
        }
        if (($prev = $exception->getPrevious()) !== null) {
            $array['previous'] = $this->convertExceptionToArray($prev);
        }

        return $array;
    }
protected function convertExceptionToArray($exception)
    {
        if (!Reaction::isDebug() && !$exception instanceof UserException && !$exception instanceof HttpException) {
            $exception = new HttpException(500, Reaction::t('rct', 'An internal server error occurred.'));
        }

        $array = [
            'name' => ($exception instanceof Exception || $exception instanceof ErrorException) ? $exception->getName() : 'Exception',
            'message' => $exception->getMessage(),
            'code' => $exception->getCode(),
        ];
        if ($exception instanceof HttpException) {
            $array['status'] = $exception->statusCode;
        }
        if (Reaction::isDebug()) {
            $array['type'] = get_class($exception);
            if (!$exception instanceof UserException) {
                $array['file'] = $exception->getFile();
                $array['line'] = $exception->getLine();
                $array['stack-trace'] = explode("\n", $exception->getTraceAsString());
            }
        }
        if (($prev = $exception->getPrevious()) !== null) {
            $array['previous'] = $this->convertExceptionToArray($prev);
        }

        return $array;
    }
protected function convertExceptionToArray ( $ exception ) { if ( ! Reaction :: isDebug ( ) && ! $ exception instanceof UserException && ! $ exception instanceof HttpException ) { $ exception = new HttpException ( 500 , Reaction :: t ( 'rct' , 'An internal server error occurred.' ) ) ; } $ array = [ 'name' => ( $ exception instanceof Exception || $ exception instanceof ErrorException ) ? $ exception -> getName ( ) : 'Exception' , 'message' => $ exception -> getMessage ( ) , 'code' => $ exception -> getCode ( ) , ] ; if ( $ exception instanceof HttpException ) { $ array [ 'status' ] = $ exception -> statusCode ; } if ( Reaction :: isDebug ( ) ) { $ array [ 'type' ] = get_class ( $ exception ) ; if ( ! $ exception instanceof UserException ) { $ array [ 'file' ] = $ exception -> getFile ( ) ; $ array [ 'line' ] = $ exception -> getLine ( ) ; $ array [ 'stack-trace' ] = explode ( "\n" , $ exception -> getTraceAsString ( ) ) ; } } if ( ( $ prev = $ exception -> getPrevious ( ) ) !== null ) { $ array [ 'previous' ] = $ this -> convertExceptionToArray ( $ prev ) ; } return $ array ; }
Converts an exception into an array.
@param \Exception|\Error $exception the exception being converted
@return array the array representation of the exception.
Converts an exception into an array .