Spaces:
Sleeping
Sleeping
Download src/core/exceptions.py from Darshankumarr03/vibesense: direct link, hf CLI and curl.
- Browser
- Download file 1.27 kB
-
https://huggingface.co/spaces/Darshankumarr03/vibesense/resolve/main/src/core/exceptions.py
- Command line
-
hf download hf://spaces/Darshankumarr03/vibesense/src/core/exceptions.py
-
curl -L -o exceptions.py https://huggingface.co/spaces/Darshankumarr03/vibesense/resolve/main/src/core/exceptions.py
1.27 kB
| class AppError(Exception): | |
| """Base class for all application errors.""" | |
| def __init__(self, message, status_code=500, payload=None): | |
| super().__init__() | |
| self.message = message | |
| self.status_code = status_code | |
| self.payload = payload | |
| def to_dict(self): | |
| rv = dict(self.payload or ()) | |
| rv['error'] = self.message | |
| rv['success'] = False | |
| return rv | |
| class ValidationError(AppError): | |
| """Raised when user input is invalid.""" | |
| def __init__(self, message, payload=None): | |
| super().__init__(message, status_code=400, payload=payload) | |
| class AuthError(AppError): | |
| """Raised during authentication failures.""" | |
| def __init__(self, message, payload=None): | |
| super().__init__(message, status_code=401, payload=payload) | |
| class DatabaseError(AppError): | |
| """Raised for database operation failures.""" | |
| def __init__(self, message, payload=None): | |
| super().__init__(message, status_code=500, payload=payload) | |
| class ExternalAPIError(AppError): | |
| """Raised when an external service (YouTube, HF, etc.) fails.""" | |
| def __init__(self, service_name, message, payload=None): | |
| msg = f"{service_name} error: {message}" | |
| super().__init__(msg, status_code=502, payload=payload) | |