rhei_core/error.rs
1//! Error types for the `rhei-core` crate.
2//!
3//! All fallible operations in this crate return [`CoreError`]. Concrete engine
4//! crates define their own error types but map into `CoreError` when crossing
5//! the shared trait boundary.
6
7use thiserror::Error;
8
9/// Top-level error type for `rhei-core` operations.
10///
11/// Variants cover schema-registry operations and Arrow type conversions.
12/// Concrete engine errors (OLTP/OLAP) are defined in their respective crates
13/// and do **not** flow through this type unless explicitly wrapped.
14#[derive(Debug, Error)]
15pub enum CoreError {
16 /// A lookup was performed for a table that has not been registered in the
17 /// [`crate::SchemaRegistry`].
18 #[error("table '{0}' not found in schema registry")]
19 TableNotFound(String),
20
21 /// An attempt was made to [`crate::SchemaRegistry::register`] a table name
22 /// that is already present. The caller should use
23 /// [`crate::SchemaRegistry::update`] for schema evolution instead.
24 #[error("table '{0}' already registered")]
25 TableAlreadyRegistered(String),
26
27 /// A schema or identifier failed validation. The inner string contains a
28 /// human-readable explanation suitable for surfacing to callers.
29 ///
30 /// Validation checks include: empty identifier, disallowed characters,
31 /// missing primary key, and duplicate column names.
32 #[error("schema validation failed: {0}")]
33 SchemaValidation(String),
34
35 /// An Arrow `DataType` could not be mapped to or from a SQL type string.
36 ///
37 /// The inner [`std::error::Error`] carries the upstream failure.
38 #[error("type mapping failed: {source}")]
39 TypeMapping {
40 /// The underlying mapping error.
41 #[source]
42 source: Box<dyn std::error::Error + Send + Sync>,
43 },
44
45 /// Transparent wrapper around [`arrow::error::ArrowError`].
46 #[error("arrow error: {0}")]
47 Arrow(#[from] arrow::error::ArrowError),
48}