|
| 1 | +# coding=utf-8 |
| 2 | + |
| 3 | +class PlexAuthError(Exception): |
| 4 | + def __init__(self, message, status_code=500, error_code=None): |
| 5 | + super().__init__(message) |
| 6 | + self.message = message |
| 7 | + self.status_code = status_code |
| 8 | + self.error_code = error_code |
| 9 | + |
| 10 | +class InvalidTokenError(PlexAuthError): |
| 11 | + def __init__(self, message="Invalid or malformed Plex authentication token. Please re-authenticate with Plex."): |
| 12 | + super().__init__(message, status_code=401, error_code="INVALID_TOKEN") |
| 13 | + |
| 14 | +class TokenExpiredError(PlexAuthError): |
| 15 | + def __init__(self, message="Plex authentication token has expired. Please re-authenticate with Plex to continue."): |
| 16 | + super().__init__(message, status_code=401, error_code="TOKEN_EXPIRED") |
| 17 | + |
| 18 | +class PlexConnectionError(PlexAuthError): |
| 19 | + def __init__(self, message="Unable to establish connection to Plex server. Please check server status and network connectivity."): |
| 20 | + super().__init__(message, status_code=503, error_code="CONNECTION_ERROR") |
| 21 | + |
| 22 | +class PlexServerNotFoundError(PlexAuthError): |
| 23 | + def __init__(self, message="Plex server not found or not accessible. Please verify server URL and authentication credentials."): |
| 24 | + super().__init__(message, status_code=404, error_code="SERVER_NOT_FOUND") |
| 25 | + |
| 26 | +class PlexPinExpiredError(PlexAuthError): |
| 27 | + def __init__(self, message="Plex authentication PIN has expired. Please request a new PIN and try again."): |
| 28 | + super().__init__(message, status_code=410, error_code="PIN_EXPIRED") |
| 29 | + |
| 30 | +class PlexAuthTimeoutError(PlexAuthError): |
| 31 | + def __init__(self, message="Plex authentication process timed out. Please try again or check your internet connection."): |
| 32 | + super().__init__(message, status_code=408, error_code="AUTH_TIMEOUT") |
| 33 | + |
| 34 | +class UnauthorizedError(PlexAuthError): |
| 35 | + def __init__(self, message="Access denied. Please check your Plex authentication credentials and permissions."): |
| 36 | + super().__init__(message, status_code=401, error_code="UNAUTHORIZED") |
0 commit comments