# app/modules/marketplace/exceptions.py """ Marketplace module exceptions. Custom exceptions for Letzshop integration, product import/export, and sync operations. """ from app.exceptions import BusinessLogicException, ResourceNotFoundException class MarketplaceException(BusinessLogicException): """Base exception for marketplace module errors.""" pass class LetzshopClientError(MarketplaceException): """Raised when Letzshop API call fails.""" def __init__(self, message: str, status_code: int | None = None, response: str | None = None): super().__init__(message) self.status_code = status_code self.response = response class LetzshopAuthenticationError(LetzshopClientError): """Raised when Letzshop authentication fails.""" def __init__(self, message: str = "Letzshop authentication failed"): super().__init__(message, status_code=401) class LetzshopCredentialsNotFoundException(ResourceNotFoundException): """Raised when Letzshop credentials not found for vendor.""" def __init__(self, vendor_id: int): super().__init__("LetzshopCredentials", str(vendor_id)) self.vendor_id = vendor_id class ImportJobNotFoundException(ResourceNotFoundException): """Raised when a marketplace import job is not found.""" def __init__(self, job_id: int): super().__init__("MarketplaceImportJob", str(job_id)) class HistoricalImportJobNotFoundException(ResourceNotFoundException): """Raised when a historical import job is not found.""" def __init__(self, job_id: int): super().__init__("LetzshopHistoricalImportJob", str(job_id)) class VendorNotFoundException(ResourceNotFoundException): """Raised when a vendor is not found.""" def __init__(self, vendor_id: int): super().__init__("Vendor", str(vendor_id)) class ProductNotFoundException(ResourceNotFoundException): """Raised when a marketplace product is not found.""" def __init__(self, product_id: str | int): super().__init__("MarketplaceProduct", str(product_id)) class ImportValidationError(MarketplaceException): """Raised when import data validation fails.""" def __init__(self, message: str, errors: list[dict] | None = None): super().__init__(message) self.errors = errors or [] class ExportError(MarketplaceException): """Raised when product export fails.""" def __init__(self, message: str, language: str | None = None): super().__init__(message) self.language = language class SyncError(MarketplaceException): """Raised when vendor directory sync fails.""" def __init__(self, message: str, vendor_code: str | None = None): super().__init__(message) self.vendor_code = vendor_code __all__ = [ "MarketplaceException", "LetzshopClientError", "LetzshopAuthenticationError", "LetzshopCredentialsNotFoundException", "ImportJobNotFoundException", "HistoricalImportJobNotFoundException", "VendorNotFoundException", "ProductNotFoundException", "ImportValidationError", "ExportError", "SyncError", ]