rag-chatbot / app /utils /errors.py
Abeshith's picture
RAG Chatbot with LangChain, FastAPI, and service layer architecture
64d7fdf
class RagChatbotError(Exception):
def __init__(self, message: str, status_code: int = 500):
self.message = message
self.status_code = status_code
super().__init__(self.message)
class DatabaseError(RagChatbotError):
def __init__(self, message: str = "Database operation failed"):
super().__init__(message, status_code=500)
class VectorStoreError(RagChatbotError):
def __init__(self, message: str = "Vector store operation failed"):
super().__init__(message, status_code=500)
class DocumentProcessingError(RagChatbotError):
def __init__(self, message: str = "Document processing failed"):
super().__init__(message, status_code=400)
class EmbeddingError(RagChatbotError):
def __init__(self, message: str = "Embedding generation failed"):
super().__init__(message, status_code=500)
class LLMError(RagChatbotError):
def __init__(self, message: str = "LLM generation failed"):
super().__init__(message, status_code=500)
class AuthenticationError(RagChatbotError):
def __init__(self, message: str = "Authentication failed"):
super().__init__(message, status_code=401)
class ValidationError(RagChatbotError):
def __init__(self, message: str = "Validation failed"):
super().__init__(message, status_code=422)