35 lines
819 B
Python
35 lines
819 B
Python
|
|
from __future__ import annotations
|
||
|
|
|
||
|
|
|
||
|
|
class RingCentralError(Exception):
|
||
|
|
def __init__(self, status_code: int, message: str):
|
||
|
|
self.status_code = status_code
|
||
|
|
self.message = message
|
||
|
|
super().__init__(f"[{status_code}] {message}")
|
||
|
|
|
||
|
|
|
||
|
|
class RingCentralAuthError(RingCentralError):
|
||
|
|
pass
|
||
|
|
|
||
|
|
|
||
|
|
class RingCentralRateLimitError(RingCentralError):
|
||
|
|
def __init__(self, status_code: int, message: str, retry_after: int = 60):
|
||
|
|
super().__init__(status_code, message)
|
||
|
|
self.retry_after = retry_after
|
||
|
|
|
||
|
|
|
||
|
|
class RingCentralNotFoundError(RingCentralError):
|
||
|
|
pass
|
||
|
|
|
||
|
|
|
||
|
|
class RingCentralValidationError(RingCentralError):
|
||
|
|
pass
|
||
|
|
|
||
|
|
|
||
|
|
class RingCentralPermissionError(RingCentralError):
|
||
|
|
pass
|
||
|
|
|
||
|
|
|
||
|
|
def is_retryable_error(status_code: int) -> bool:
|
||
|
|
return status_code == 429 or status_code >= 500
|