datalogic_rs/error/kind.rs
1use datavalue::OwnedDataValue;
2use std::borrow::Cow;
3use std::sync::Arc;
4
5/// Trait-object alias for the source carried by [`ErrorKind::Custom`].
6/// Reference-counted so [`ErrorKind`] stays cheap to clone, and bounded
7/// so a single `crate::Error` value can be sent across threads.
8pub type CustomErrorSource = Arc<dyn std::error::Error + Send + Sync + 'static>;
9
10/// Discriminant for [`crate::Error`]. Stable variant tags are exposed via
11/// [`crate::Error::tag`] for matching across releases.
12#[non_exhaustive]
13#[derive(Debug, Clone)]
14pub enum ErrorKind {
15 /// Invalid operator name
16 InvalidOperator(Cow<'static, str>),
17 /// Invalid arguments for an operator
18 InvalidArguments(Cow<'static, str>),
19 /// Variable not found in context
20 VariableNotFound(Cow<'static, str>),
21 /// Invalid context level access
22 InvalidContextLevel(isize),
23 /// Type conversion/coercion error
24 TypeError(Cow<'static, str>),
25 /// Arithmetic error (division by zero, overflow, etc.)
26 ArithmeticError(Cow<'static, str>),
27 /// Custom error for extensions. Carries the underlying typed error so
28 /// callers can walk the source chain via [`std::error::Error::source`].
29 /// Constructed via [`crate::Error::custom_message`] (string-only) or
30 /// [`crate::Error::wrap`] (any `std::error::Error + Send + Sync + 'static`).
31 Custom(CustomErrorSource),
32 /// JSON parsing/serialization error
33 ParseError(Cow<'static, str>),
34 /// Thrown error from throw operator
35 Thrown(OwnedDataValue),
36 /// Invalid format string or pattern
37 FormatError(Cow<'static, str>),
38 /// Index out of bounds for array operations
39 IndexOutOfBounds { index: isize, length: usize },
40 /// Invalid operator configuration
41 ConfigurationError(Cow<'static, str>),
42}