Download core/exceptions/base.py from Rsnarsna/Saas-Base: direct link, hf CLI and curl.
- Browser
- Download file 1.59 kB
-
https://huggingface.co/spaces/Rsnarsna/Saas-Base/resolve/main/core/exceptions/base.py
- Command line
-
hf download hf://spaces/Rsnarsna/Saas-Base/core/exceptions/base.py
-
curl -L -o base.py https://huggingface.co/spaces/Rsnarsna/Saas-Base/resolve/main/core/exceptions/base.py
1.59 kB
| """ | |
| Core exceptions — standard error hierarchy for all apps. | |
| All app-level exceptions should inherit from AppError. | |
| """ | |
| class AppError(Exception): | |
| """Base exception for all application errors.""" | |
| def __init__(self, message: str = "An application error occurred.", code: str = "APP_ERROR"): | |
| self.message = message | |
| self.code = code | |
| super().__init__(self.message) | |
| class AuthenticationError(AppError): | |
| """Authentication-related errors.""" | |
| def __init__(self, message: str = "Authentication failed."): | |
| super().__init__(message, code="AUTH_ERROR") | |
| class AuthorizationError(AppError): | |
| """Authorization/permission errors.""" | |
| def __init__(self, message: str = "Permission denied."): | |
| super().__init__(message, code="AUTHZ_ERROR") | |
| class ValidationError(AppError): | |
| """Business-rule validation errors.""" | |
| def __init__(self, message: str = "Validation failed."): | |
| super().__init__(message, code="VALIDATION_ERROR") | |
| class NotFoundError(AppError): | |
| """Resource not found errors.""" | |
| def __init__(self, message: str = "Resource not found."): | |
| super().__init__(message, code="NOT_FOUND") | |
| class RateLimitError(AppError): | |
| """Rate limiting errors.""" | |
| def __init__(self, message: str = "Too many requests. Please try again later."): | |
| super().__init__(message, code="RATE_LIMIT") | |
| class EncryptionError(AppError): | |
| """Encryption/decryption errors.""" | |
| def __init__(self, message: str = "Encryption operation failed."): | |
| super().__init__(message, code="ENCRYPTION_ERROR") | |