Add custom exceptions handling
This commit is contained in:
120
app/exceptions/__init__.py
Normal file
120
app/exceptions/__init__.py
Normal file
@@ -0,0 +1,120 @@
|
||||
# app/exceptions/__init__.py
|
||||
"""
|
||||
Custom exception classes for the LetzShop API.
|
||||
|
||||
This module provides frontend-friendly exceptions with consistent error codes,
|
||||
messages, and HTTP status mappings.
|
||||
"""
|
||||
|
||||
from .base import (
|
||||
LetzShopException,
|
||||
ValidationException,
|
||||
AuthenticationException,
|
||||
AuthorizationException,
|
||||
ResourceNotFoundException,
|
||||
ConflictException,
|
||||
BusinessLogicException,
|
||||
ExternalServiceException,
|
||||
RateLimitException,
|
||||
)
|
||||
|
||||
from .auth import (
|
||||
InvalidCredentialsException,
|
||||
TokenExpiredException,
|
||||
InsufficientPermissionsException,
|
||||
UserNotActiveException,
|
||||
AdminRequiredException,
|
||||
)
|
||||
|
||||
from .product import (
|
||||
ProductNotFoundException,
|
||||
ProductAlreadyExistsException,
|
||||
InvalidProductDataException,
|
||||
ProductValidationException,
|
||||
)
|
||||
|
||||
from .stock import (
|
||||
StockNotFoundException,
|
||||
InsufficientStockException,
|
||||
InvalidStockOperationException,
|
||||
StockValidationException,
|
||||
)
|
||||
|
||||
from .shop import (
|
||||
ShopNotFoundException,
|
||||
ShopAlreadyExistsException,
|
||||
ShopNotActiveException,
|
||||
ShopNotVerifiedException,
|
||||
UnauthorizedShopAccessException,
|
||||
InvalidShopDataException,
|
||||
)
|
||||
|
||||
from .marketplace import (
|
||||
MarketplaceImportException,
|
||||
ImportJobNotFoundException,
|
||||
ImportJobNotOwnedException,
|
||||
InvalidImportDataException,
|
||||
ImportJobCannotBeCancelledException,
|
||||
ImportJobCannotBeDeletedException,
|
||||
)
|
||||
|
||||
from .admin import (
|
||||
UserNotFoundException,
|
||||
UserStatusChangeException,
|
||||
ShopVerificationException,
|
||||
AdminOperationException,
|
||||
)
|
||||
|
||||
__all__ = [
|
||||
# Base exceptions
|
||||
"LetzShopException",
|
||||
"ValidationException",
|
||||
"AuthenticationException",
|
||||
"AuthorizationException",
|
||||
"ResourceNotFoundException",
|
||||
"ConflictException",
|
||||
"BusinessLogicException",
|
||||
"ExternalServiceException",
|
||||
"RateLimitException",
|
||||
|
||||
# Auth exceptions
|
||||
"InvalidCredentialsException",
|
||||
"TokenExpiredException",
|
||||
"InsufficientPermissionsException",
|
||||
"UserNotActiveException",
|
||||
"AdminRequiredException",
|
||||
|
||||
# Product exceptions
|
||||
"ProductNotFoundException",
|
||||
"ProductAlreadyExistsException",
|
||||
"InvalidProductDataException",
|
||||
"ProductValidationException",
|
||||
|
||||
# Stock exceptions
|
||||
"StockNotFoundException",
|
||||
"InsufficientStockException",
|
||||
"InvalidStockOperationException",
|
||||
"StockValidationException",
|
||||
|
||||
# Shop exceptions
|
||||
"ShopNotFoundException",
|
||||
"ShopAlreadyExistsException",
|
||||
"ShopNotActiveException",
|
||||
"ShopNotVerifiedException",
|
||||
"UnauthorizedShopAccessException",
|
||||
"InvalidShopDataException",
|
||||
|
||||
# Marketplace exceptions
|
||||
"MarketplaceImportException",
|
||||
"ImportJobNotFoundException",
|
||||
"ImportJobNotOwnedException",
|
||||
"InvalidImportDataException",
|
||||
"ImportJobCannotBeCancelledException",
|
||||
"ImportJobCannotBeDeletedException",
|
||||
|
||||
# Admin exceptions
|
||||
"UserNotFoundException",
|
||||
"UserStatusChangeException",
|
||||
"ShopVerificationException",
|
||||
"AdminOperationException",
|
||||
]
|
||||
Reference in New Issue
Block a user