hyf-backend/th_agenter/core/exceptions.py

52 lines
1.2 KiB
Python
Raw Normal View History

2026-01-21 13:45:39 +08:00
"""Custom exceptions for the application."""
from typing import Any, Dict, Optional
class BaseCustomException(Exception):
"""Base custom exception class."""
def __init__(self, message: str, details: Optional[Dict[str, Any]] = None):
self.message = message
self.details = details or {}
super().__init__(self.message)
class NotFoundError(BaseCustomException):
"""Exception raised when a resource is not found."""
pass
class ValidationError(BaseCustomException):
"""Exception raised when validation fails."""
pass
class AuthenticationError(BaseCustomException):
"""Exception raised when authentication fails."""
pass
class AuthorizationError(BaseCustomException):
"""Exception raised when authorization fails."""
pass
class DatabaseError(BaseCustomException):
"""Exception raised when database operations fail."""
pass
class ConfigurationError(BaseCustomException):
"""Exception raised when configuration is invalid."""
pass
class ExternalServiceError(BaseCustomException):
"""Exception raised when external service calls fail."""
pass
class BusinessLogicError(BaseCustomException):
"""Exception raised when business logic validation fails."""
pass