Coverage for /home/admin/Documents/AI/applications/lexigram-dev/lexigram/experimental/ai/lexigram-ai-memory/src/lexigram/ai/memory/exceptions.py: 80%
20 statements
« prev ^ index » next coverage.py v7.15.4, created at 2026-08-25 07:19 +0800
« prev ^ index » next coverage.py v7.15.4, created at 2026-08-25 07:19 +0800
1"""Exceptions for lexigram-ai-memory."""
3from __future__ import annotations
5from lexigram.contracts.ai.exceptions import AIMemoryError as _ContractsAIMemoryError
6from lexigram.contracts.ai.memory import ConsolidationError
9class MemorySystemError(_ContractsAIMemoryError):
10 """Base exception for memory operations."""
12 _code: str = "LEX_ERR_MEM_005"
15class MemoryStoreError(MemorySystemError):
16 """Raised when a backend store operation fails."""
18 _code: str = "LEX_ERR_MEM_006"
20 def __init__(self, message: str, store: str | None = None) -> None:
21 """Initialise with optional store name context.
23 Args:
24 message: Human-readable description.
25 store: Name of the store that raised the error.
26 """
27 super().__init__(message)
28 self.store = store
31class MemoryCapacityError(MemorySystemError):
32 """Raised when a memory store is at capacity and cannot accept new entries."""
34 _code: str = "LEX_ERR_MEM_008"
36 def __init__(self, message: str, capacity: int | None = None) -> None:
37 """Initialise with optional capacity context.
39 Args:
40 message: Human-readable description.
41 capacity: Maximum capacity that was exceeded.
42 """
43 super().__init__(message)
44 self.capacity = capacity
47class EmbeddingError(MemorySystemError):
48 """Raised when generating or storing an embedding fails."""
50 _code: str = "LEX_ERR_MEM_009"
53class FactExtractionError(MemorySystemError):
54 """Raised when entity/fact extraction from text fails."""
56 _code: str = "LEX_ERR_MEM_010"
59__all__ = [
60 "ConsolidationError",
61 "EmbeddingError",
62 "FactExtractionError",
63 "MemoryCapacityError",
64 "MemoryStoreError",
65 "MemorySystemError",
66]