use std::fmt;
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum ApplyError {
UnknownOperator(String),
InvalidArguments(String),
CustomOpFailed { op: String, source: String },
#[doc(hidden)]
FuelExceeded,
}
impl fmt::Display for ApplyError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::UnknownOperator(op) => write!(f, "unknown operator: {op}"),
Self::InvalidArguments(msg) => write!(f, "invalid arguments: {msg}"),
Self::CustomOpFailed { op, source } => {
write!(f, "custom operator '{op}' failed: {source}")
}
Self::FuelExceeded => write!(f, "fuel budget exhausted"),
}
}
}
impl std::error::Error for ApplyError {}
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum GuardError {
Malformed(String),
MissingVar(String),
TypeError(String),
FuelExceeded { limit: usize },
CustomOpFailed { op: String, source: String },
}
impl fmt::Display for GuardError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::Malformed(msg) => write!(f, "guard rule malformed: {msg}"),
Self::MissingVar(path) => write!(f, "guard references missing variable '{path}'"),
Self::TypeError(msg) => write!(f, "guard type error: {msg}"),
Self::FuelExceeded { limit } => {
write!(f, "guard rule too complex (node limit: {limit})")
}
Self::CustomOpFailed { op, source } => {
write!(f, "custom operator '{op}' failed: {source}")
}
}
}
}
impl std::error::Error for GuardError {}