Files
wehub-resource-sync 4a19d70af1
CodeQL Advanced / Analyze (actions) (push) Waiting to run
CodeQL Advanced / Analyze (python) (push) Waiting to run
Tests / database-integration-tests (push) Waiting to run
MCP Server Tests / live-mcp-tests (push) Waiting to run
Server Tests / live-server-tests (push) Waiting to run
Pyright Type Check / pyright (push) Waiting to run
Tests / unit-tests (push) Waiting to run
Lint with Ruff / ruff (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:38:54 +08:00

96 lines
3.1 KiB
Python

"""
Copyright 2024, Zep Software, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""
class GraphitiError(Exception):
"""Base exception class for Graphiti Core."""
class EdgeNotFoundError(GraphitiError):
"""Raised when an edge is not found."""
def __init__(self, uuid: str):
self.message = f'edge {uuid} not found'
super().__init__(self.message)
class EdgesNotFoundError(GraphitiError):
"""Raised when a list of edges is not found."""
def __init__(self, uuids: list[str]):
self.message = f'None of the edges for {uuids} were found.'
super().__init__(self.message)
class GroupsEdgesNotFoundError(GraphitiError):
"""Raised when no edges are found for a list of group ids."""
def __init__(self, group_ids: list[str]):
self.message = f'no edges found for group ids {group_ids}'
super().__init__(self.message)
class GroupsNodesNotFoundError(GraphitiError):
"""Raised when no nodes are found for a list of group ids."""
def __init__(self, group_ids: list[str]):
self.message = f'no nodes found for group ids {group_ids}'
super().__init__(self.message)
class NodeNotFoundError(GraphitiError):
"""Raised when a node is not found."""
def __init__(self, uuid: str):
self.message = f'node {uuid} not found'
super().__init__(self.message)
class SearchRerankerError(GraphitiError):
"""Raised when a node is not found."""
def __init__(self, text: str):
self.message = text
super().__init__(self.message)
class EntityTypeValidationError(GraphitiError):
"""Raised when an entity type uses protected attribute names."""
def __init__(self, entity_type: str, entity_type_attribute: str):
self.message = f'{entity_type_attribute} cannot be used as an attribute for {entity_type} as it is a protected attribute name.'
super().__init__(self.message)
class GroupIdValidationError(GraphitiError):
"""Raised when a group_id contains invalid characters."""
def __init__(self, group_id: str):
self.message = f'group_id "{group_id}" must contain only alphanumeric characters, dashes, or underscores'
super().__init__(self.message)
class NodeLabelValidationError(GraphitiError, ValueError):
"""Raised when a node label contains invalid characters."""
def __init__(self, node_labels: list[str]):
label_list = ', '.join(f'"{label}"' for label in node_labels)
self.message = (
'node_labels must start with a letter or underscore and contain only '
f'alphanumeric characters or underscores: {label_list}'
)
super().__init__(self.message)