Raised when the key has been terminated
| 74 | |
| 75 | # api key with no permission |
| 76 | class AccessTerminatedException(Exception): |
| 77 | "Raised when the key has been terminated" |
| 78 | def __init__(self, |
| 79 | key: str, |
| 80 | cause: Optional[str] = None) -> None: |
| 81 | super().__init__(f"Access terminated key: {key}") |
| 82 | self.key = key |
| 83 | self.cause = cause |
| 84 | |
| 85 | def __str__(self) -> str: |
| 86 | if self.cause: |
| 87 | return f"{super().__str__()}. Caused by {self.cause}" |
| 88 | else: |
| 89 | return super().__str__() |
| 90 | |
| 91 | |
| 92 | def track_usage(res_json: dict) -> dict: |