Skip to main content

simple_zanzibar/
error.rs

1//! Defines custom error types for the application.
2use thiserror::Error;
3
4use crate::{
5    domain::DomainError, eval::EvaluationError, relationship::StoreError,
6    revision::ConsistencyError, schema::SchemaError,
7};
8
9/// Top-level error returned by the compatibility service and public helper APIs.
10#[derive(Error, Debug, PartialEq)]
11pub enum ZanzibarError {
12    /// Requested namespace is not configured.
13    #[error("Namespace '{0}' not found")]
14    NamespaceNotFound(String),
15
16    /// Requested relation is not configured in the namespace.
17    #[error("Relation '{0}' not found in namespace '{1}'")]
18    RelationNotFound(String, String),
19
20    /// DSL parsing failed.
21    #[error("Parsing error: {0}")]
22    ParseError(String),
23
24    /// Legacy tuple store operation failed.
25    #[error("Storage error: {0}")]
26    StorageError(String),
27
28    /// Operation requires a loaded schema snapshot.
29    #[error("Schema must be loaded before applying relationship batches")]
30    SchemaRequired,
31
32    /// Domain validation failed.
33    #[error(transparent)]
34    Domain(#[from] DomainError),
35
36    /// Schema compilation or validation failed.
37    #[error(transparent)]
38    Schema(#[from] SchemaError),
39
40    /// Indexed relationship store operation failed.
41    #[error(transparent)]
42    Store(#[from] StoreError),
43
44    /// Consistency token validation failed.
45    #[error(transparent)]
46    Consistency(#[from] ConsistencyError),
47
48    /// Graph evaluation failed.
49    #[error(transparent)]
50    Evaluation(#[from] EvaluationError),
51}