

def validate_response(response, content=None):
    '\n    raises AttributeError if the HTTP response code is not 200, or if the value\n    returned by the server indicates an error.\n\n    :param response:    the response returned by a call to urllib.request.urlopen\n    :type response:     file-like object\n    :param content:     the JSON-deserialized value returned by the server.\n                        This is required if the response was "read" prior to\n                        calling this method.\n    :type content:      any iterable collection \n    :returns:           None\n    :raises:            AttributeError\n    '
    if (response.getcode() != 200):
        raise AttributeError(('HTTP code %d. %s' % (error_field.code, response.msg)))
    if (content is None):
        content = json.loads(response.read().decode('utf-8'))
    for error_field in ('error_msg', 'error'):
        if (error_field in content):
            raise AttributeError(('Error message from thermostat: %s' % content[error_field]))

dataset/ETHPy150Open mhrivnak/radiotherm/radiotherm/validate.py validate_response/VarMisuse@36/241 `response`->`error_field`