From 6870bba5a90285e87f066095a3a878865c343fad Mon Sep 17 00:00:00 2001 From: hajdul88 <52442977+hajdul88@users.noreply.github.com> Date: Wed, 13 Aug 2025 12:03:18 +0200 Subject: [PATCH] feat: adds new error to delete --- cognee/modules/data/exceptions/exceptions.py | 10 ++++++++++ cognee/modules/data/methods/delete_data.py | 6 ++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/cognee/modules/data/exceptions/exceptions.py b/cognee/modules/data/exceptions/exceptions.py index 4eff8f9b8..c85e11cb2 100644 --- a/cognee/modules/data/exceptions/exceptions.py +++ b/cognee/modules/data/exceptions/exceptions.py @@ -43,3 +43,13 @@ class DatasetTypeError(CogneeValidationError): status_code=status.HTTP_400_BAD_REQUEST, ): super().__init__(message, name, status_code) + + +class InvalidAttributeError(CogneeValidationError): + def __init__( + self, + message: str = "The provided data object is missing the required '__tablename__' attribute.", + name: str = "InvalidAttributeError", + status_code: int = status.HTTP_400_BAD_REQUEST, + ): + super().__init__(message, name, status_code) diff --git a/cognee/modules/data/methods/delete_data.py b/cognee/modules/data/methods/delete_data.py index 2d87d73a5..6ec055fcc 100644 --- a/cognee/modules/data/methods/delete_data.py +++ b/cognee/modules/data/methods/delete_data.py @@ -1,4 +1,4 @@ -from cognee.exceptions import InvalidAttributeError +from cognee.modules.data.exceptions.exceptions import InvalidAttributeError from cognee.modules.data.models import Data from cognee.infrastructure.databases.relational import get_relational_engine @@ -13,9 +13,7 @@ async def delete_data(data: Data): ValueError: If the data object is invalid. """ if not hasattr(data, "__tablename__"): - raise InvalidAttributeError( - message="The provided data object is missing the required '__tablename__' attribute." - ) + raise InvalidAttributeError() db_engine = get_relational_engine()