Skip to main content

nodedb_physical/
error.rs

1// SPDX-License-Identifier: Apache-2.0
2
3//! Error type for the shared SqlPlan → PhysicalPlan converter helpers.
4//!
5//! The variant set matches what the converter actually produces; deeper
6//! engine-specific failures are re-wrapped at the deployment boundary.
7//! Origin maps `ConvertError → nodedb::Error`; Lite will map it to its
8//! own error type.
9
10use crate::surrogate::SurrogateAssignError;
11
12#[derive(Debug, thiserror::Error)]
13pub enum ConvertError {
14    /// The plan shape is invalid (unsupported combination, missing field, etc.).
15    #[error("plan error: {0}")]
16    PlanError(String),
17
18    /// A client-facing request is malformed (bad cast, wrong literal type, etc.).
19    #[error("bad request: {0}")]
20    BadRequest(String),
21
22    /// A defensive cap was exceeded (max fan-out, depth, columns, etc.).
23    #[error("{limit_name} exceeded: {value} > {max}")]
24    LimitExceeded {
25        limit_name: &'static str,
26        value: u64,
27        max: u64,
28    },
29
30    /// Surrogate allocation failed.
31    #[error(transparent)]
32    Surrogate(#[from] SurrogateAssignError),
33
34    /// Serialization failure (msgpack encoding of filters, projections, etc.).
35    #[error("serialization: {0}")]
36    Serialization(String),
37
38    /// Catch-all for converter-internal failures that don't fit the above
39    /// and that we don't want to leak from the shared crate as untyped strings.
40    /// Carries a `'static` short reason; full detail propagates via `cause`.
41    #[error("converter internal: {0}")]
42    Other(String),
43}