Skip to main content

volas_core/
error.rs

1//! Error type for the volas core kernel.
2
3use thiserror::Error;
4
5/// Errors raised by the volas core. The Python binding maps each variant to a
6/// typed exception (see `volas-python`).
7#[derive(Debug, Error, Clone, PartialEq)]
8pub enum VolasError {
9    /// A column name was not found in the frame.
10    #[error("column \"{0}\" not found")]
11    ColumnNotFound(String),
12
13    /// A dtype-incompatible operation (e.g. appending Bool onto F64).
14    #[error("dtype error: {0}")]
15    DType(String),
16
17    /// Mismatched lengths / shapes (e.g. columns of unequal height).
18    #[error("shape error: {0}")]
19    Shape(String),
20
21    /// Out-of-range or otherwise invalid index access.
22    #[error("index error: {0}")]
23    Index(String),
24
25    /// A bad argument value.
26    #[error("value error: {0}")]
27    Value(String),
28
29    /// A directive string that could not be tokenized / parsed (a *syntax* error,
30    /// annotated with line / column), as opposed to a [`Value`](Self::Value) error
31    /// for a well-formed directive with an invalid command / argument.
32    #[error("parse error: {0}")]
33    Parse(String),
34}
35
36/// Convenience result alias used throughout the core.
37pub type Result<T> = std::result::Result<T, VolasError>;