private function throwRequestException($statusCode, $response)
    {
        if ($response && isset($response->error)) {
            $type = $response->error->type;
            $message = $this->getResponseErrorMessage($response->error);
            $link = $response->error->link;
        } elseif ($this->isServerErrorResponse($statusCode)) {
            $type = 'Server Error';
            $message = RequestException::$statusTexts[$statusCode];
            $link = '';
        } else {
            $type = 'Client Error';
            $message = RequestException::$statusTexts[$statusCode];
            $link = '';
        }

        throw new RequestException($type, $message, $link, $statusCode);
    }