src/Exception/Builder.php
public static function fromHttpRequestAndResponse(
        HttpRequest $request,
        HttpResponse $response
    ) {
        $message = '';
        $jsonResponse = $response->getJsonResult();

        $errors = self::parseErrorsFromResponse($response);
        if (isset($jsonResponse->type, $jsonResponse->message)) {
            $message .= $jsonResponse->message;
            if (!empty($errors)) {
                $message .= ' | ' . $errors;
            }
            return new ApiResponseException(
                $message,
                $response->getCode(),
                null,
                $request,
                $response
            );
        }

        if ($response->getMessage()) {
            $message .= $response->getMessage();
        }
        if (!empty($errors)) {
            $message .= ' | ' . $errors;
        }
        return new HttpResponseException(
            $message,
            $response->getCode(),
            null,
            $request,
            $response
        );
    }
public static function fromHttpRequestAndResponse(
        HttpRequest $request,
        HttpResponse $response
    ) {
        $message = '';
        $jsonResponse = $response->getJsonResult();

        $errors = self::parseErrorsFromResponse($response);
        if (isset($jsonResponse->type, $jsonResponse->message)) {
            $message .= $jsonResponse->message;
            if (!empty($errors)) {
                $message .= ' | ' . $errors;
            }
            return new ApiResponseException(
                $message,
                $response->getCode(),
                null,
                $request,
                $response
            );
        }

        if ($response->getMessage()) {
            $message .= $response->getMessage();
        }
        if (!empty($errors)) {
            $message .= ' | ' . $errors;
        }
        return new HttpResponseException(
            $message,
            $response->getCode(),
            null,
            $request,
            $response
        );
    }
public static function fromHttpRequestAndResponse ( HttpRequest $ request , HttpResponse $ response ) { $ message = '' ; $ jsonResponse = $ response -> getJsonResult ( ) ; $ errors = self :: parseErrorsFromResponse ( $ response ) ; if ( isset ( $ jsonResponse -> type , $ jsonResponse -> message ) ) { $ message .= $ jsonResponse -> message ; if ( ! empty ( $ errors ) ) { $ message .= ' | ' . $ errors ; } return new ApiResponseException ( $ message , $ response -> getCode ( ) , null , $ request , $ response ) ; } if ( $ response -> getMessage ( ) ) { $ message .= $ response -> getMessage ( ) ; } if ( ! empty ( $ errors ) ) { $ message .= ' | ' . $ errors ; } return new HttpResponseException ( $ message , $ response -> getCode ( ) , null , $ request , $ response ) ; }
Return HttpException exception with info about both the
request and response.

@param HttpRequest $request
@param HttpResponse $response
@return AbstractHttpException|HttpResponseException
Return HttpException exception with info about both the request and response .