1use std::fmt;
2
3#[derive(Debug, Clone, PartialEq, Eq)]
5pub enum ApplyError {
6 UnknownOperator(String),
7 InvalidArguments(String),
8 CustomOpFailed { op: String, source: String },
11 #[doc(hidden)]
14 FuelExceeded,
15}
16
17impl fmt::Display for ApplyError {
18 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
19 match self {
20 Self::UnknownOperator(op) => write!(f, "unknown operator: {op}"),
21 Self::InvalidArguments(msg) => write!(f, "invalid arguments: {msg}"),
22 Self::CustomOpFailed { op, source } => {
23 write!(f, "custom operator '{op}' failed: {source}")
24 }
25 Self::FuelExceeded => write!(f, "fuel budget exhausted"),
26 }
27 }
28}
29
30impl std::error::Error for ApplyError {}
31
32#[derive(Debug, Clone, PartialEq, Eq)]
34pub enum GuardError {
35 Malformed(String),
37 MissingVar(String),
40 TypeError(String),
42 FuelExceeded { limit: usize },
44 CustomOpFailed { op: String, source: String },
46}
47
48impl fmt::Display for GuardError {
49 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
50 match self {
51 Self::Malformed(msg) => write!(f, "guard rule malformed: {msg}"),
52 Self::MissingVar(path) => write!(f, "guard references missing variable '{path}'"),
53 Self::TypeError(msg) => write!(f, "guard type error: {msg}"),
54 Self::FuelExceeded { limit } => {
55 write!(f, "guard rule too complex (node limit: {limit})")
56 }
57 Self::CustomOpFailed { op, source } => {
58 write!(f, "custom operator '{op}' failed: {source}")
59 }
60 }
61 }
62}
63
64impl std::error::Error for GuardError {}