Skip to main content

uni_query_functions/rewrite/
error.rs

1//! Error types for query rewriting operations
2
3/// Errors that can occur during query rewriting
4#[derive(Debug, Clone, PartialEq, Eq, Hash, thiserror::Error)]
5pub enum RewriteError {
6    /// Function has wrong number of arguments
7    #[error("Function arity mismatch: expected {expected} arguments, got {got}")]
8    ArityMismatch { expected: usize, got: usize },
9
10    /// Function argument arity is out of expected range
11    #[error("Function arity out of range: expected {min}-{max} arguments, got {got}")]
12    ArityOutOfRange { min: usize, max: usize, got: usize },
13
14    /// Expected a string literal for property name but got dynamic expression
15    #[error("Expected string literal at argument {arg_index}, got dynamic expression")]
16    ExpectedStringLiteral { arg_index: usize },
17
18    /// Expected an entity reference (variable) but got different type
19    #[error("Expected entity reference at argument {arg_index}, got different type")]
20    ExpectedEntityReference { arg_index: usize },
21
22    /// Argument has unexpected type
23    #[error("Type error at argument {arg_index}: expected {expected}, got {got}")]
24    TypeError {
25        arg_index: usize,
26        expected: String,
27        got: String,
28    },
29
30    /// Rewrite rule is not applicable in current context
31    #[error("Rewrite not applicable: {reason}")]
32    NotApplicable { reason: String },
33
34    /// Internal error during rewrite transformation
35    #[error("Transform error: {message}")]
36    TransformError { message: String },
37
38    /// Missing required context information
39    #[error("Missing required context: {required}")]
40    MissingContext { required: String },
41}