Skip to main content

rhei_olap/
error.rs

1//! Unified error types for the OLAP and OLTP backend dispatchers.
2//!
3//! [`OlapError`] and [`OltpError`] wrap the backend-specific error types produced by
4//! `rhei-duckdb`, `rhei-datafusion`, and `rhei-oltp-rusqlite`.  The `From` conversions are
5//! derived by [`thiserror`] so that `.map_err(OlapError::from)` in each dispatch arm compiles
6//! without boilerplate.
7
8use thiserror::Error;
9
10/// Error type returned by [`crate::OlapBackend`] method implementations.
11///
12/// Each variant corresponds to one supported OLAP backend plus a catch-all [`OlapError::Other`]
13/// for errors that do not originate from a specific engine.
14#[derive(Debug, Error)]
15pub enum OlapError {
16    /// An error returned by the DuckDB backend.
17    ///
18    /// Available on crate feature `duckdb-backend` only.
19    #[cfg(feature = "duckdb-backend")]
20    #[error("DuckDB error: {0}")]
21    DuckDb(#[from] rhei_duckdb::DuckDbError),
22
23    /// An error returned by the DataFusion backend.
24    ///
25    /// Available on crate feature `datafusion-backend` only.
26    #[cfg(feature = "datafusion-backend")]
27    #[error("DataFusion error: {0}")]
28    DataFusion(#[from] rhei_datafusion::DfOlapError),
29
30    /// A generic OLAP error not tied to a specific backend.
31    #[error("{0}")]
32    Other(String),
33}
34
35/// Error type returned by [`crate::OltpBackend`] method implementations.
36///
37/// Each variant corresponds to one supported OLTP backend plus a catch-all [`OltpError::Other`]
38/// for errors that do not originate from a specific engine.
39#[derive(Debug, Error)]
40pub enum OltpError {
41    /// An error returned by the Rusqlite (SQLite) backend.
42    #[error("rusqlite OLTP error: {0}")]
43    Rusqlite(#[from] rhei_oltp_rusqlite::RusqliteOltpError),
44
45    /// A generic OLTP error not tied to a specific backend.
46    #[error("{0}")]
47    Other(String),
48}