Skip to main content

automapper_validation/
error.rs

1//! Error types for the automapper-validation crate.
2
3/// Errors that can occur during condition expression parsing.
4#[derive(Debug, Clone, thiserror::Error)]
5pub enum ParseError {
6    /// Unexpected token encountered during parsing.
7    #[error("unexpected token at position {position}: expected {expected}, found '{found}'")]
8    UnexpectedToken {
9        position: usize,
10        expected: String,
11        found: String,
12    },
13
14    /// Unmatched closing parenthesis.
15    #[error("unmatched closing parenthesis at position {position}")]
16    UnmatchedCloseParen { position: usize },
17
18    /// Empty expression after stripping prefix.
19    #[error("empty expression after stripping status prefix")]
20    EmptyExpression,
21
22    /// Invalid condition reference content.
23    #[error("invalid condition reference: '{content}'")]
24    InvalidConditionRef { content: String },
25}
26
27/// Errors that can occur during validation.
28#[derive(Debug, thiserror::Error)]
29pub enum ValidationError {
30    /// Condition expression parse error.
31    #[error("condition expression parse error: {0}")]
32    ConditionParse(#[from] ParseError),
33
34    /// Unknown Pruefidentifikator.
35    #[error("unknown Pruefidentifikator: '{0}'")]
36    UnknownPruefidentifikator(String),
37
38    /// No evaluator registered for message type and format version.
39    #[error("no condition evaluator registered for {message_type}/{format_version}")]
40    NoEvaluator {
41        message_type: String,
42        format_version: String,
43    },
44}