Error
- class cf_rules.Error(message: str | None = None)[source]
- __init__(message: str | None = None) Error [source]
Error class to handle Cloudflare errors
>>> error = Error() # OR >>> error = Error("This is an error message")
- handle(request_json: dict, keys: list[str | int]) any [source]
Handle errors from a request response
- Raises:
Error – If auth error
>>> error.handle({"success": True, "result": {"a": "b"}}, ["success"]) >>> True
>>> error.handle({"success": False, "errors": [{"code": "invalid_parameter", "message": "Invalid parameter"}]}, ["success"]) >>> False
>>> error.handle({"success": False, "errors": [{"code": 9109, "message": "Invalid access token"}], "messages": [], "result": None}, ["errors"][0]["message"]) >>> "Invalid access token"