35 lines
1.2 KiB
Python
35 lines
1.2 KiB
Python
# app/exceptions/vendor.py
|
|
"""
|
|
Vendor management specific exceptions.
|
|
"""
|
|
|
|
from .base import (
|
|
ResourceNotFoundException,
|
|
ConflictException
|
|
)
|
|
|
|
class ProductAlreadyExistsException(ConflictException):
|
|
"""Raised when trying to add a product that already exists in vendor."""
|
|
|
|
def __init__(self, vendor_code: str, marketplace_product_id: str):
|
|
super().__init__(
|
|
message=f"MarketplaceProduct '{marketplace_product_id}' already exists in vendor '{vendor_code}'",
|
|
error_code="PRODUCT_ALREADY_EXISTS",
|
|
details={
|
|
"vendor_code": vendor_code,
|
|
"marketplace_product_id": marketplace_product_id,
|
|
},
|
|
)
|
|
|
|
|
|
class ProductNotFoundException(ResourceNotFoundException):
|
|
"""Raised when a vendor product relationship is not found."""
|
|
|
|
def __init__(self, vendor_code: str, marketplace_product_id: str):
|
|
super().__init__(
|
|
resource_type="Product",
|
|
identifier=f"{vendor_code}/{marketplace_product_id}",
|
|
message=f"MarketplaceProduct '{marketplace_product_id}' not found in vendor '{vendor_code}'",
|
|
error_code="PRODUCT_NOT_FOUND",
|
|
)
|