Skip to main content

pflow_tokenmodel/
error.rs

1//! Error types for tokenmodel operations.
2
3use thiserror::Error;
4
5#[derive(Debug, Error)]
6pub enum Error {
7    // Schema validation errors
8    #[error("tokenmodel: element has empty ID")]
9    EmptyId,
10
11    #[error("tokenmodel: duplicate element ID: {0}")]
12    DuplicateId(String),
13
14    #[error("tokenmodel: arc source not found: {0}")]
15    InvalidArcSource(String),
16
17    #[error("tokenmodel: arc target not found: {0}")]
18    InvalidArcTarget(String),
19
20    #[error("tokenmodel: arcs must connect states to actions")]
21    InvalidArcConnection,
22
23    // Execution errors
24    #[error("tokenmodel: action not found: {0}")]
25    ActionNotFound(String),
26
27    #[error("tokenmodel: insufficient tokens to execute")]
28    InsufficientTokens,
29
30    #[error("tokenmodel: action guard not satisfied")]
31    GuardNotSatisfied,
32
33    #[error("tokenmodel: guard evaluation error: {0}")]
34    GuardEvaluation(String),
35
36    #[error("tokenmodel: action not enabled: {0}")]
37    ActionNotEnabled(String),
38
39    // Constraint errors
40    #[error("tokenmodel: constraint violated: {0}")]
41    ConstraintViolated(String),
42
43    #[error("tokenmodel: constraint evaluation error: {0}: {1}")]
44    ConstraintEvaluation(String, String),
45}
46
47pub type Result<T> = std::result::Result<T, Error>;