(
cls,
status: int,
headers: dict[str, Any],
output: dict[str, Any],
)
| 935 | |
| 936 | @classmethod |
| 937 | def createException( |
| 938 | cls, |
| 939 | status: int, |
| 940 | headers: dict[str, Any], |
| 941 | output: dict[str, Any], |
| 942 | ) -> GithubException.GithubException: |
| 943 | message = output.get("message") if output else None |
| 944 | lc_message = message.lower() if message else "" |
| 945 | |
| 946 | msg = None |
| 947 | exc = GithubException.GithubException |
| 948 | if status == 401 and lc_message == "bad credentials": |
| 949 | exc = GithubException.BadCredentialsException |
| 950 | elif status == 401 and Consts.headerOTP in headers and re.match(r".*required.*", headers[Consts.headerOTP]): |
| 951 | exc = GithubException.TwoFactorException |
| 952 | elif status == 403 and lc_message.startswith("missing or invalid user agent string"): |
| 953 | exc = GithubException.BadUserAgentException |
| 954 | elif status == 403 and cls.isRateLimitError(lc_message): |
| 955 | exc = GithubException.RateLimitExceededException |
| 956 | elif status == 404 and ("not found" in lc_message or "no object found" in lc_message): |
| 957 | exc = GithubException.UnknownObjectException |
| 958 | if lc_message != "not found": |
| 959 | msg = message |
| 960 | else: |
| 961 | # for general GithubException, provide the actual message |
| 962 | msg = message |
| 963 | |
| 964 | return exc(status, output, headers, msg) |
| 965 | |
| 966 | @classmethod |
| 967 | def isRateLimitError(cls, message: str) -> bool: |
no test coverage detected