def handle_response(self, method, response):
        try:
            data = response.json(object_hook=self.get_json_object_hook)
        except __HOLE__:
            data = None

        if response.status_code == 200:
            return ApiResponse(response, method, data)

        if data is None:
            raise TwitterApiError(
                'Unable to decode JSON response.',
                response=response,
                request_method=method,
            )

        error_code, error_msg = self.get_twitter_error_details(data)
        kwargs = {
            'response': response,
            'request_method': method,
            'error_code': error_code,
        }

        if response.status_code == 401 or 'Bad Authentication data' in error_msg:
            raise TwitterAuthError(error_msg, **kwargs)

        if response.status_code == 404:
            raise TwitterApiError('Invalid API resource.', **kwargs)

        if response.status_code == 429:
            raise TwitterRateLimitError(error_msg, **kwargs)

        raise TwitterApiError(error_msg, **kwargs)
dataset/ETHPy150Open inueni/birdy/birdy/twitter.py/BaseTwitterClient.handle_response