Coverage for openhcs/core/memory/exceptions.py: 25.0%
8 statements
« prev ^ index » next coverage.py v7.10.3, created at 2025-08-14 05:57 +0000
« prev ^ index » next coverage.py v7.10.3, created at 2025-08-14 05:57 +0000
1"""
2Memory conversion exceptions for OpenHCS.
4This module defines exceptions for memory conversion operations,
5enforcing Clause 65 (Fail Loudly) and Clause 88 (No Inferred Capabilities).
6"""
10class MemoryConversionError(Exception):
11 """
12 Exception raised when memory conversion fails.
14 This exception is raised when a memory conversion operation fails and
15 CPU fallback is not explicitly authorized.
17 Attributes:
18 source_type: The source memory type
19 target_type: The target memory type
20 method: The conversion method that was attempted
21 reason: The reason for the failure
22 """
24 def __init__(self, source_type: str, target_type: str, method: str, reason: str):
25 """
26 Initialize a MemoryConversionError.
28 Args:
29 source_type: The source memory type
30 target_type: The target memory type
31 method: The conversion method that was attempted
32 reason: The reason for the failure
33 """
34 self.source_type = source_type
35 self.target_type = target_type
36 self.method = method
37 self.reason = reason
39 message = (
40 f"Cannot convert from {source_type} to {target_type} using {method}. "
41 f"Reason: {reason}. "
42 f"No CPU fallback permitted unless explicitly authorized via allow_cpu_roundtrip=True."
43 )
45 super().__init__(message)