src/JSONClient.php
public static function handleError(BadResponseException $exception)
    {
        $response_body = (string) $exception->getResponse()->getBody();
        $array_body = decode($response_body);

        $code = $exception->getResponse()->getStatusCode();

        $lookForKeys = ['message', 'code', 'error'];

        foreach ($lookForKeys as $key) {
            if (isset($array_body[$key])) {
                $message = $array_body[$key];
            }
        }

        if (!$message) {
            $message = 'unknown_error';
        }

        throw new JSONError($message, $code, $array_body);
    }
public static function handleError(BadResponseException $exception)
    {
        $response_body = (string) $exception->getResponse()->getBody();
        $array_body = decode($response_body);

        $code = $exception->getResponse()->getStatusCode();

        $lookForKeys = ['message', 'code', 'error'];

        foreach ($lookForKeys as $key) {
            if (isset($array_body[$key])) {
                $message = $array_body[$key];
            }
        }

        if (!$message) {
            $message = 'unknown_error';
        }

        throw new JSONError($message, $code, $array_body);
    }
public static function handleError ( BadResponseException $ exception ) { $ response_body = ( string ) $ exception -> getResponse ( ) -> getBody ( ) ; $ array_body = decode ( $ response_body ) ; $ code = $ exception -> getResponse ( ) -> getStatusCode ( ) ; $ lookForKeys = [ 'message' , 'code' , 'error' ] ; foreach ( $ lookForKeys as $ key ) { if ( isset ( $ array_body [ $ key ] ) ) { $ message = $ array_body [ $ key ] ; } } if ( ! $ message ) { $ message = 'unknown_error' ; } throw new JSONError ( $ message , $ code , $ array_body ) ; }
Handles the error for us, just a bit of code abstraction.

@param BadResponseException $exception

@throws JSONError
Handles the error for us just a bit of code abstraction .