Migrates marketplace module to self-contained structure: - Create app/modules/marketplace/services/ re-exporting from existing locations - Create app/modules/marketplace/models/ with marketplace & letzshop models - Create app/modules/marketplace/schemas/ with product & import schemas - Create app/modules/marketplace/tasks/ with 5 Celery tasks: - process_marketplace_import - CSV product import - process_historical_import - Letzshop order import - sync_vendor_directory - Scheduled daily vendor sync - export_vendor_products_to_folder - Multi-language export - export_marketplace_products - Admin export - Create app/modules/marketplace/exceptions.py - Update definition.py with is_self_contained=True and scheduled_tasks Celery task migration: - process_marketplace_import, process_historical_import -> import_tasks.py - sync_vendor_directory -> sync_tasks.py (scheduled daily at 02:00) - export_vendor_products_to_folder, export_marketplace_products -> export_tasks.py Backward compatibility: - Legacy task files now re-export from new locations - Remove marketplace/letzshop/export from LEGACY_TASK_MODULES Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
106 lines
3.1 KiB
Python
106 lines
3.1 KiB
Python
# 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",
|
|
]
|