-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path__init__.py
More file actions
28 lines (18 loc) · 950 Bytes
/
__init__.py
File metadata and controls
28 lines (18 loc) · 950 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
class TraktAPIError(Exception):
"""Exception raised when Trakt API requests fail."""
def __init__(self, message: str, status_code: int | None = None):
self.message = message
self.status_code = status_code
super().__init__(self.message)
class AuthenticationError(TraktAPIError):
"""Exception raised when authentication fails."""
def __init__(self, message: str = "Authentication required. Please configure TRAKT_ACCESS_TOKEN."):
super().__init__(message, status_code=401)
class ResourceNotFoundError(TraktAPIError):
"""Exception raised when a resource is not found."""
def __init__(self, message: str = "Resource not found on Trakt"):
super().__init__(message, status_code=404)
class NetworkError(TraktAPIError):
"""Exception raised when network requests fail."""
def __init__(self, message: str):
super().__init__(f"Network error: {message}", status_code=None)