chronicle/error.rs
1//! Error types for the Chronicle crate.
2//!
3//! Defines [`ChronicleError`], the unified error enum returned by loading,
4//! validation, and query operations.
5
6use thiserror::Error;
7
8/// Errors that can occur when loading, validating, or querying a Chronicle graph.
9#[derive(Debug, Error)]
10pub enum ChronicleError {
11 /// A lookup by entity ID found no matching node in the graph.
12 #[error("entity not found: {0}")]
13 EntityNotFound(String),
14
15 /// Two or more entities share the same ID, which must be unique.
16 #[error("duplicate entity id: {0}")]
17 DuplicateId(String),
18
19 /// An entity references another entity ID that does not exist in the graph.
20 #[error("dangling reference: {source_id} references unknown entity {target_id}")]
21 DanglingReference {
22 /// The ID of the entity that contains the broken reference.
23 source_id: String,
24 /// The ID that was referenced but not found.
25 target_id: String,
26 },
27
28 /// A temporal constraint (Allen's Interval Algebra) is violated between events.
29 #[error("temporal violation: {description}")]
30 TemporalViolation {
31 /// Human-readable explanation of the temporal inconsistency.
32 description: String,
33 },
34
35 /// An event conflicts with the current state of a participant or location
36 /// (e.g. a dead actor participating, or a destroyed place hosting an event).
37 #[error("state violation: {description}")]
38 StateViolation {
39 /// Human-readable explanation of the state conflict.
40 description: String,
41 },
42
43 /// A RON file could not be parsed.
44 #[error("parse error: {0}")]
45 Parse(#[from] ron::error::SpannedError),
46
47 /// A filesystem I/O operation failed while reading world data.
48 #[error("io error: {0}")]
49 Io(#[from] std::io::Error),
50}