protected function handle(ResponseInterface $response)
    {
        $httpException = new HttpException($response->getStatusCode(), $response->getReasonPhrase());

        // 4xx will content error information in the body encoded as JSON
        if (!in_array($response->getStatusCode(), range(400, 417))) {
            throw $httpException;
        }

        $error = json_decode((string) $response->getBody());
        $message = '';
        foreach ($error->errors as $i => $e) {
            $message .= sprintf(
                "ERROR #%d: \nField: %s \nMessage: %s \nHelp: %s\n\n\n",
                $i,
                isset($e->field) ? $e->field : '-',
                isset($e->message) ? $e->message : '-',
                isset($e->help) ? $e->help : '-'
            );
        }

        throw new ApiException($message, $httpException);
    }
protected function handle(ResponseInterface $response)
    {
        $httpException = new HttpException($response->getStatusCode(), $response->getReasonPhrase());

        
        if (!in_array($response->getStatusCode(), range(400, 417))) {
            throw $httpException;
        }

        $error = json_decode((string) $response->getBody());
        $message = '';
        foreach ($error->errors as $i => $e) {
            $message .= sprintf(
                "ERROR 
                $i,
                isset($e->field) ? $e->field : '-',
                isset($e->message) ? $e->message : '-',
                isset($e->help) ? $e->help : '-'
            );
        }

        throw new ApiException($message, $httpException);
    }
protected function handle ( ResponseInterface $ response ) { $ httpException = new HttpException ( $ response -> getStatusCode ( ) , $ response -> getReasonPhrase ( ) ) ; // 4xx will content error information in the body encoded as JSON if ( ! in_array ( $ response -> getStatusCode ( ) , range ( 400 , 417 ) ) ) { throw $ httpException ; } $ error = json_decode ( ( string ) $ response -> getBody ( ) ) ; $ message = '' ; foreach ( $ error -> errors as $ i => $ e ) { $ message .= sprintf ( "ERROR #%d: \nField: %s \nMessage: %s \nHelp: %s\n\n\n" , $ i , isset ( $ e -> field ) ? $ e -> field : '-' , isset ( $ e -> message ) ? $ e -> message : '-' , isset ( $ e -> help ) ? $ e -> help : '-' ) ; } throw new ApiException ( $ message , $ httpException ) ; }
{@inheritdoc}
{