feat: adds new error to delete

This commit is contained in:
hajdul88 2025-08-13 12:03:18 +02:00
parent 7bd2660d08
commit 6870bba5a9
2 changed files with 12 additions and 4 deletions

View file

@ -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)

View file

@ -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()