diff --git a/cognee/modules/search/exceptions/__init__.py b/cognee/modules/search/exceptions/__init__.py new file mode 100644 index 000000000..ffb30f428 --- /dev/null +++ b/cognee/modules/search/exceptions/__init__.py @@ -0,0 +1,9 @@ +""" +Custom exceptions for the Cognee API. + +This module defines a set of exceptions for handling various data errors +""" + +from .exceptions import ( + UnsupportedSearchTypeError +) diff --git a/cognee/modules/search/exceptions/exceptions.py b/cognee/modules/search/exceptions/exceptions.py new file mode 100644 index 000000000..ddc877700 --- /dev/null +++ b/cognee/modules/search/exceptions/exceptions.py @@ -0,0 +1,15 @@ +from cognee.exceptions import ( + CogneeValidationError, +) +from fastapi import status + + +class UnsupportedSearchTypeError(CogneeValidationError): + def __init__( + self, + search_type: str, + name: str = "UnsupportedSearchTypeError", + status_code: int = status.HTTP_400_BAD_REQUEST, + ): + message = f"Unsupported search type: {search_type}" + super().__init__(message, name, status_code) diff --git a/cognee/modules/search/methods/search.py b/cognee/modules/search/methods/search.py index 365920019..f431a498e 100644 --- a/cognee/modules/search/methods/search.py +++ b/cognee/modules/search/methods/search.py @@ -3,9 +3,8 @@ import json import asyncio from uuid import UUID from typing import Callable, List, Optional, Type, Union - +from cognee.modules.search.exceptions import UnsupportedSearchTypeError from cognee.context_global_variables import set_database_global_context_variables -from cognee.exceptions import InvalidValueError from cognee.modules.retrieval.chunks_retriever import ChunksRetriever from cognee.modules.retrieval.insights_retriever import InsightsRetriever from cognee.modules.retrieval.summaries_retriever import SummariesRetriever @@ -136,7 +135,7 @@ async def specific_search( search_task = search_tasks.get(query_type) if search_task is None: - raise InvalidValueError(message=f"Unsupported search type: {query_type}") + raise UnsupportedSearchTypeError(str(query_type)) send_telemetry("cognee.search EXECUTION STARTED", user.id)