309 lines
8.6 KiB
Python
309 lines
8.6 KiB
Python
# app/exceptions/__init__.py
|
|
"""
|
|
Custom exception classes for the API.
|
|
|
|
This module provides frontend-friendly exceptions with consistent error codes,
|
|
messages, and HTTP status mappings.
|
|
"""
|
|
|
|
# Base exceptions
|
|
from .base import (
|
|
WizamartException,
|
|
ValidationException,
|
|
AuthenticationException,
|
|
AuthorizationException,
|
|
ResourceNotFoundException,
|
|
ConflictException,
|
|
BusinessLogicException,
|
|
ExternalServiceException,
|
|
RateLimitException,
|
|
ServiceUnavailableException,
|
|
)
|
|
|
|
# Authentication exceptions
|
|
from .auth import (
|
|
InvalidCredentialsException,
|
|
TokenExpiredException,
|
|
InvalidTokenException,
|
|
InsufficientPermissionsException,
|
|
UserNotActiveException,
|
|
AdminRequiredException,
|
|
UserAlreadyExistsException
|
|
)
|
|
|
|
# Admin exceptions
|
|
from .admin import (
|
|
UserNotFoundException,
|
|
UserStatusChangeException,
|
|
VendorVerificationException,
|
|
AdminOperationException,
|
|
CannotModifyAdminException,
|
|
CannotModifySelfException,
|
|
InvalidAdminActionException,
|
|
BulkOperationException,
|
|
ConfirmationRequiredException,
|
|
)
|
|
|
|
# Marketplace import job exceptions
|
|
from .marketplace_import_job import (
|
|
MarketplaceImportException,
|
|
ImportJobNotFoundException,
|
|
ImportJobNotOwnedException,
|
|
InvalidImportDataException,
|
|
ImportJobCannotBeCancelledException,
|
|
ImportJobCannotBeDeletedException,
|
|
MarketplaceConnectionException,
|
|
MarketplaceDataParsingException,
|
|
ImportRateLimitException,
|
|
InvalidMarketplaceException,
|
|
ImportJobAlreadyProcessingException,
|
|
)
|
|
|
|
# Marketplace product exceptions
|
|
from .marketplace_product import (
|
|
MarketplaceProductNotFoundException,
|
|
MarketplaceProductAlreadyExistsException,
|
|
InvalidMarketplaceProductDataException,
|
|
MarketplaceProductValidationException,
|
|
InvalidGTINException,
|
|
MarketplaceProductCSVImportException,
|
|
)
|
|
|
|
# Inventory exceptions
|
|
from .inventory import (
|
|
InventoryNotFoundException,
|
|
InsufficientInventoryException,
|
|
InvalidInventoryOperationException,
|
|
InventoryValidationException,
|
|
NegativeInventoryException,
|
|
InvalidQuantityException,
|
|
LocationNotFoundException
|
|
)
|
|
|
|
# Vendor exceptions
|
|
from .vendor import (
|
|
VendorNotFoundException,
|
|
VendorAlreadyExistsException,
|
|
VendorNotActiveException,
|
|
VendorNotVerifiedException,
|
|
UnauthorizedVendorAccessException,
|
|
InvalidVendorDataException,
|
|
MaxVendorsReachedException,
|
|
VendorValidationException,
|
|
)
|
|
|
|
# Vendor domain exceptions
|
|
from .vendor_domain import (
|
|
VendorDomainNotFoundException,
|
|
VendorDomainAlreadyExistsException,
|
|
InvalidDomainFormatException,
|
|
ReservedDomainException,
|
|
DomainNotVerifiedException,
|
|
DomainVerificationFailedException,
|
|
DomainAlreadyVerifiedException,
|
|
MultiplePrimaryDomainsException,
|
|
DNSVerificationException,
|
|
MaxDomainsReachedException,
|
|
UnauthorizedDomainAccessException,
|
|
)
|
|
|
|
# Vendor theme exceptions
|
|
from .vendor_theme import (
|
|
VendorThemeNotFoundException,
|
|
InvalidThemeDataException,
|
|
ThemePresetNotFoundException,
|
|
ThemeValidationException,
|
|
ThemePresetAlreadyAppliedException,
|
|
InvalidColorFormatException,
|
|
InvalidFontFamilyException,
|
|
ThemeOperationException,
|
|
)
|
|
|
|
# Customer exceptions
|
|
from .customer import (
|
|
CustomerNotFoundException,
|
|
CustomerAlreadyExistsException,
|
|
DuplicateCustomerEmailException,
|
|
CustomerNotActiveException,
|
|
InvalidCustomerCredentialsException,
|
|
CustomerValidationException,
|
|
CustomerAuthorizationException,
|
|
)
|
|
|
|
# Team exceptions
|
|
from .team import (
|
|
TeamMemberNotFoundException,
|
|
TeamMemberAlreadyExistsException,
|
|
TeamInvitationNotFoundException,
|
|
TeamInvitationExpiredException,
|
|
TeamInvitationAlreadyAcceptedException,
|
|
UnauthorizedTeamActionException,
|
|
CannotRemoveOwnerException,
|
|
CannotModifyOwnRoleException,
|
|
RoleNotFoundException,
|
|
InvalidRoleException,
|
|
InsufficientPermissionsException,
|
|
MaxTeamMembersReachedException,
|
|
TeamValidationException,
|
|
InvalidInvitationDataException,
|
|
)
|
|
|
|
# Product exceptions
|
|
from .product import (
|
|
ProductNotFoundException,
|
|
ProductAlreadyExistsException,
|
|
ProductNotInCatalogException,
|
|
ProductNotActiveException,
|
|
InvalidProductDataException,
|
|
ProductValidationException,
|
|
CannotDeleteProductWithInventoryException,
|
|
CannotDeleteProductWithOrdersException,
|
|
)
|
|
|
|
# Order exceptions
|
|
from .order import (
|
|
OrderNotFoundException,
|
|
OrderAlreadyExistsException,
|
|
OrderValidationException,
|
|
InvalidOrderStatusException,
|
|
OrderCannotBeCancelledException,
|
|
)
|
|
|
|
__all__ = [
|
|
# Base exceptions
|
|
"WizamartException",
|
|
"ValidationException",
|
|
"AuthenticationException",
|
|
"AuthorizationException",
|
|
"ResourceNotFoundException",
|
|
"ConflictException",
|
|
"BusinessLogicException",
|
|
"ExternalServiceException",
|
|
"RateLimitException",
|
|
"ServiceUnavailableException",
|
|
|
|
# Auth exceptions
|
|
"InvalidCredentialsException",
|
|
"TokenExpiredException",
|
|
"InvalidTokenException",
|
|
"InsufficientPermissionsException",
|
|
"UserNotActiveException",
|
|
"AdminRequiredException",
|
|
"UserAlreadyExistsException",
|
|
|
|
# Customer exceptions
|
|
"CustomerNotFoundException",
|
|
"CustomerAlreadyExistsException",
|
|
"DuplicateCustomerEmailException",
|
|
"CustomerNotActiveException",
|
|
"InvalidCustomerCredentialsException",
|
|
"CustomerValidationException",
|
|
"CustomerAuthorizationException",
|
|
|
|
# Team exceptions
|
|
"TeamMemberNotFoundException",
|
|
"TeamMemberAlreadyExistsException",
|
|
"TeamInvitationNotFoundException",
|
|
"TeamInvitationExpiredException",
|
|
"TeamInvitationAlreadyAcceptedException",
|
|
"UnauthorizedTeamActionException",
|
|
"CannotRemoveOwnerException",
|
|
"CannotModifyOwnRoleException",
|
|
"RoleNotFoundException",
|
|
"InvalidRoleException",
|
|
"InsufficientPermissionsException",
|
|
"MaxTeamMembersReachedException",
|
|
"TeamValidationException",
|
|
"InvalidInvitationDataException",
|
|
|
|
# Inventory exceptions
|
|
"InventoryNotFoundException",
|
|
"InsufficientInventoryException",
|
|
"InvalidInventoryOperationException",
|
|
"InventoryValidationException",
|
|
"NegativeInventoryException",
|
|
"InvalidQuantityException",
|
|
"LocationNotFoundException",
|
|
|
|
# Vendor exceptions
|
|
"VendorNotFoundException",
|
|
"VendorAlreadyExistsException",
|
|
"VendorNotActiveException",
|
|
"VendorNotVerifiedException",
|
|
"UnauthorizedVendorAccessException",
|
|
"InvalidVendorDataException",
|
|
"MaxVendorsReachedException",
|
|
"VendorValidationException",
|
|
|
|
# Vendor Domain
|
|
"VendorDomainNotFoundException",
|
|
"VendorDomainAlreadyExistsException",
|
|
"InvalidDomainFormatException",
|
|
"ReservedDomainException",
|
|
"DomainNotVerifiedException",
|
|
"DomainVerificationFailedException",
|
|
"DomainAlreadyVerifiedException",
|
|
"MultiplePrimaryDomainsException",
|
|
"DNSVerificationException",
|
|
"MaxDomainsReachedException",
|
|
"UnauthorizedDomainAccessException",
|
|
|
|
# Vendor Theme
|
|
"VendorThemeNotFoundException",
|
|
"InvalidThemeDataException",
|
|
"ThemePresetNotFoundException",
|
|
"ThemeValidationException",
|
|
"ThemePresetAlreadyAppliedException",
|
|
"InvalidColorFormatException",
|
|
"InvalidFontFamilyException",
|
|
"ThemeOperationException",
|
|
|
|
# Product exceptions
|
|
"ProductNotFoundException",
|
|
"ProductAlreadyExistsException",
|
|
"ProductNotInCatalogException",
|
|
"ProductNotActiveException",
|
|
"InvalidProductDataException",
|
|
"ProductValidationException",
|
|
"CannotDeleteProductWithInventoryException",
|
|
"CannotDeleteProductWithOrdersException",
|
|
|
|
# Order exceptions
|
|
"OrderNotFoundException",
|
|
"OrderAlreadyExistsException",
|
|
"OrderValidationException",
|
|
"InvalidOrderStatusException",
|
|
"OrderCannotBeCancelledException",
|
|
|
|
# MarketplaceProduct exceptions
|
|
"MarketplaceProductNotFoundException",
|
|
"MarketplaceProductAlreadyExistsException",
|
|
"InvalidMarketplaceProductDataException",
|
|
"MarketplaceProductValidationException",
|
|
"InvalidGTINException",
|
|
"MarketplaceProductCSVImportException",
|
|
|
|
# Marketplace import exceptions
|
|
"MarketplaceImportException",
|
|
"ImportJobNotFoundException",
|
|
"ImportJobNotOwnedException",
|
|
"InvalidImportDataException",
|
|
"ImportJobCannotBeCancelledException",
|
|
"ImportJobCannotBeDeletedException",
|
|
"MarketplaceConnectionException",
|
|
"MarketplaceDataParsingException",
|
|
"ImportRateLimitException",
|
|
"InvalidMarketplaceException",
|
|
"ImportJobAlreadyProcessingException",
|
|
|
|
# Admin exceptions
|
|
"UserNotFoundException",
|
|
"UserStatusChangeException",
|
|
"VendorVerificationException",
|
|
"AdminOperationException",
|
|
"CannotModifyAdminException",
|
|
"CannotModifySelfException",
|
|
"InvalidAdminActionException",
|
|
"BulkOperationException",
|
|
"ConfirmationRequiredException",
|
|
] |