src/pqc_audit_log_fs/errors.py
| 1 | """Exception hierarchy for pqc-audit-log-fs.""" |
| 2 | |
| 3 | from __future__ import annotations |
| 4 | |
| 5 | |
| 6 | class AuditLogError(Exception): |
| 7 | """Base exception for all pqc-audit-log-fs errors.""" |
| 8 | |
| 9 | |
| 10 | class AppendToSealedSegmentError(AuditLogError): |
| 11 | """Raised when attempting to append to a sealed or closed segment.""" |
| 12 | |
| 13 | |
| 14 | class SegmentCorruptedError(AuditLogError): |
| 15 | """Raised when a segment's merkle root does not match its recomputed root, |
| 16 | or when a segment jsonl file contains malformed data.""" |
| 17 | |
| 18 | |
| 19 | class SignatureVerificationError(AuditLogError): |
| 20 | """Raised when a segment header's ML-DSA signature fails to verify.""" |
| 21 | |
| 22 | |
| 23 | class ChainBrokenError(AuditLogError): |
| 24 | """Raised when a segment's previous_segment_root does not match the |
| 25 | preceding segment's merkle_root.""" |
| 26 | |
| 27 | |
| 28 | class SegmentNotFoundError(AuditLogError): |
| 29 | """Raised when a referenced segment (or event within) does not exist.""" |
| 30 | |
| 31 | |
| 32 | class ImmutabilityViolationError(AuditLogError): |
| 33 | """Raised when the FilesystemGuard cannot enforce immutability (strict mode).""" |
| 34 | |