replyflow-rag / core /exceptions.py
Qurrah's picture
REFINE: add DocumentNotFoundError exception for handling document not found scenarios
edbb770
Raw History Blame Contribute Delete
1.43 kB
class BaseAppException(Exception):
"""Base exception for all application-specific errors."""
def __init__(self, message: str, status_code: int = 400):
self.message = message
self.status_code = status_code
super().__init__(self.message)
class WorkspaceNotFoundError(BaseAppException):
"""Raised when a workspace or brand is not found."""
def __init__(self, message: str = "Workspace not found"):
super().__init__(message, status_code=404)
class DocumentNotFoundError(BaseAppException):
"""Raised when a document is not found."""
def __init__(self, message: str = "Document not found"):
super().__init__(message, status_code=404)
class ShopifyError(BaseAppException):
"""Base for Shopify-related errors."""
pass
class ShopifyTimeoutError(ShopifyError):
def __init__(self, message: str = "Shopify request timed out"):
super().__init__(message, status_code=504)
class ShopifyConnectionError(ShopifyError):
def __init__(self, message: str = "Could not connect to Shopify"):
super().__init__(message, status_code=502)
class RateLimitExceeded(BaseAppException):
def __init__(self, message: str = "Rate limit exceeded"):
super().__init__(message, status_code=429)
class InvalidRequestError(BaseAppException):
def __init__(self, message: str = "Invalid request"):
super().__init__(message, status_code=400)