Skip to main content

qs_strategy/
error.rs

1use crate::{ScalarType, ValueType};
2
3/// A terminal configuration compilation failure.
4#[derive(Debug, Clone, PartialEq, thiserror::Error)]
5pub enum CompileError {
6    #[error("invalid identifier at {path}: {reason}")]
7    InvalidIdentifier { path: String, reason: String },
8    #[error("duplicate identifier at {path}: {id}")]
9    DuplicateIdentifier { path: String, id: String },
10    #[error("unknown material key at {path}: {key}")]
11    UnknownMaterialKey { path: String, key: String },
12    #[error("unknown reference at {path}: {reference}")]
13    UnknownReference { path: String, reference: String },
14    #[error("material dependency cycle: {materials:?}")]
15    DependencyCycle { materials: Vec<String> },
16    #[error("type mismatch at {path}: expected {expected:?}, got {actual:?}")]
17    TypeMismatch {
18        path: String,
19        expected: ValueType,
20        actual: ValueType,
21    },
22    #[error("invalid optional-to-required flow at {path}")]
23    OptionalToRequired { path: String },
24    #[error("invalid state target at {path}: {target}")]
25    InvalidStateTarget { path: String, target: String },
26    #[error("transition priority conflict in state {state}: {priority}")]
27    PriorityConflict { state: String, priority: i32 },
28    #[error("unreachable state: {state}")]
29    UnreachableState { state: String },
30    #[error("invalid configuration at {path}: {reason}")]
31    InvalidConfig { path: String, reason: String },
32    #[error("configured bound exceeded at {path}: {actual} > {limit}")]
33    ExcessiveBound {
34        path: String,
35        actual: usize,
36        limit: usize,
37    },
38    #[error("generated identity capacity is invalid")]
39    InvalidIdCapacity,
40    #[error("material factory failed at {path}: {reason}")]
41    MaterialFactory { path: String, reason: String },
42}
43
44/// A terminal strategy evaluation failure.
45#[derive(Debug, Clone, PartialEq, thiserror::Error)]
46pub enum EvaluationError {
47    #[error("arithmetic overflow at {path}")]
48    ArithmeticOverflow { path: String },
49    #[error("division by zero at {path}")]
50    DivisionByZero { path: String },
51    #[error("non-finite result at {path}")]
52    NonFinite { path: String },
53    #[error("required value is missing at {path}")]
54    MissingRequired { path: String },
55    #[error("runtime type mismatch at {path}: expected {expected:?}, got {actual:?}")]
56    TypeMismatch {
57        path: String,
58        expected: ScalarType,
59        actual: Option<ScalarType>,
60    },
61    #[error("material evaluation failed for {material}: {reason}")]
62    Material { material: String, reason: String },
63    #[error("invalid generated action at {path}: {reason}")]
64    InvalidAction { path: String, reason: String },
65    #[error("generated identity counter exhausted: {kind}")]
66    CounterExhausted { kind: &'static str },
67    #[error("generated identity exceeds the configured bound")]
68    IdCapacity,
69    #[error("runtime output bound exceeded: {kind}")]
70    OutputBound { kind: &'static str },
71    #[error("strategy is terminal after a previous evaluation error")]
72    Terminal,
73}