lib/Core/ApiClient.php
private function handleErrors($response)
    {
        $json = json_decode($response->getBody());

        if ($json === null) {
            $msg = "Malformed response received from server";
            throw new Exception\MalformedResponseException($msg, $response);
        }

        if ($response->getStatusCode() < 400) {
            return null;
        }

        $error = $json->error;
        $exception_class = (string) ApiException::getErrorForType($error->type);
        $exception_class = 'GoCardlessPro\\Core\\Exception\\' . $exception_class;

        $api_response = new ApiResponse($response);
        throw new $exception_class($api_response);
    }
private function handleErrors($response)
    {
        $json = json_decode($response->getBody());

        if ($json === null) {
            $msg = "Malformed response received from server";
            throw new Exception\MalformedResponseException($msg, $response);
        }

        if ($response->getStatusCode() < 400) {
            return null;
        }

        $error = $json->error;
        $exception_class = (string) ApiException::getErrorForType($error->type);
        $exception_class = 'GoCardlessPro\\Core\\Exception\\' . $exception_class;

        $api_response = new ApiResponse($response);
        throw new $exception_class($api_response);
    }
private function handleErrors ( $ response ) { $ json = json_decode ( $ response -> getBody ( ) ) ; if ( $ json === null ) { $ msg = "Malformed response received from server" ; throw new Exception \ MalformedResponseException ( $ msg , $ response ) ; } if ( $ response -> getStatusCode ( ) < 400 ) { return null ; } $ error = $ json -> error ; $ exception_class = ( string ) ApiException :: getErrorForType ( $ error -> type ) ; $ exception_class = 'GoCardlessPro\\Core\\Exception\\' . $ exception_class ; $ api_response = new ApiResponse ( $ response ) ; throw new $ exception_class ( $ api_response ) ; }
Handle any errors in the API response

If the response doesn't contain JSON, we will fail to decode and throw a
MalFormedResponseException.

If the response is JSON, but the status code is >= 400, then we return
the appropriate error depending on the code

@param GuzzleHttp\Psr7\Response $response The raw API response
Handle any errors in the API response