def from_response(response, method, url):
    """Returns an instance of :class:`HttpError` or subclass based on response.

    :param response: instance of `requests.Response` class
    :param method: HTTP method used for request
    :param url: URL used for request
    """
    kwargs = {
        "http_status": response.status_code,
        "response": response,
        "method": method,
        "url": url,
        "request_id": response.headers.get("x-compute-request-id"),
    }
    if "retry-after" in response.headers:
        kwargs["retry_after"] = response.headers["retry-after"]

    content_type = response.headers.get("Content-Type", "")
    if content_type.startswith("application/json"):
        try:
            body = response.json()
        except ValueError:
            pass
        else:
            if isinstance(body, dict):
                kwargs["message"] = body.get("faultstring")
                kwargs["details"] = body.get("debuginfo")
    elif content_type.startswith("text/"):
        kwargs["details"] = response.text

    try:
        cls = exceptions._code_map[response.status_code]
    except KeyError:
        if 500 <= 600 < response.status_code:
            cls = exceptions.HttpServerError
        elif 400 <= response.status_code < 500:
            cls = exceptions.HTTPClientError
        else:
            cls = exceptions.HttpError
    return cls(**kwargs)
dataset/ETHPy150Open openstack/python-solumclient/solumclient/common/exc.py/from_response/swapped operands of `<`