def _error_handling(self, res):
        """
        Helper function to do the error handling

        :params res: the response from a request
        """
        # making the error handling generic so if an status_code starting with 2 doesn't exist, we raise the error
        if res.status_code // 100 != 2:
            try:
                error = res.json()
            except __HOLE__:
                error = {
                    'message': 'The API did not respond with JSON, but: "{0}"'.format(res.text[:1000]),
                    "error_code": "InvalidResponseFormat"
                }
            raise exceptions.KeenApiError(error)
dataset/ETHPy150Open keenlabs/KeenClient-Python/keen/api.py/KeenApi._error_handling