private function parseExceptionForErrorMessages(Exception $e)
    {
        if (! $e instanceof BadResponseException) {
            throw new ApiException($e->getMessage());
        }

        $response = $e->getResponse();
        Psr7\rewind_body($response);
        $responseBody = $response->getBody()->getContents();
        $decodedResponseBody = json_decode($responseBody, true);

        if (! is_null($decodedResponseBody) && isset($decodedResponseBody['error']['message']['value'])) {
            $errorMessage = $decodedResponseBody['error']['message']['value'];
        } else {
            $errorMessage = $responseBody;
        }

        throw new ApiException('Error ' . $response->getStatusCode() . ': ' . $errorMessage, $response->getStatusCode());
    }
private function parseExceptionForErrorMessages(Exception $e)
    {
        if (! $e instanceof BadResponseException) {
            throw new ApiException($e->getMessage());
        }

        $response = $e->getResponse();
        Psr7\rewind_body($response);
        $responseBody = $response->getBody()->getContents();
        $decodedResponseBody = json_decode($responseBody, true);

        if (! is_null($decodedResponseBody) && isset($decodedResponseBody['error']['message']['value'])) {
            $errorMessage = $decodedResponseBody['error']['message']['value'];
        } else {
            $errorMessage = $responseBody;
        }

        throw new ApiException('Error ' . $response->getStatusCode() . ': ' . $errorMessage, $response->getStatusCode());
    }
private function parseExceptionForErrorMessages ( Exception $ e ) { if ( ! $ e instanceof BadResponseException ) { throw new ApiException ( $ e -> getMessage ( ) ) ; } $ response = $ e -> getResponse ( ) ; Psr7 \ rewind_body ( $ response ) ; $ responseBody = $ response -> getBody ( ) -> getContents ( ) ; $ decodedResponseBody = json_decode ( $ responseBody , true ) ; if ( ! is_null ( $ decodedResponseBody ) && isset ( $ decodedResponseBody [ 'error' ] [ 'message' ] [ 'value' ] ) ) { $ errorMessage = $ decodedResponseBody [ 'error' ] [ 'message' ] [ 'value' ] ; } else { $ errorMessage = $ responseBody ; } throw new ApiException ( 'Error ' . $ response -> getStatusCode ( ) . ': ' . $ errorMessage , $ response -> getStatusCode ( ) ) ; }
Parse the reponse in the Exception to return the Exact error messages.

@param Exception $e

@throws ApiException
Parse the reponse in the Exception to return the Exact error messages .