1use arrow::error::ArrowError;
4
5#[derive(Debug, thiserror::Error)]
7pub enum NdError {
8 #[error(transparent)]
10 Arrow(#[from] ArrowError),
11 #[error("invalid dimensions: {0}")]
13 InvalidDimensions(String),
14 #[error("shape mismatch: {0}")]
16 ShapeMismatch(String),
17 #[error("invalid attribute: {0}")]
19 InvalidAttribute(String),
20 #[error("invalid nd encoding: {0}")]
22 InvalidEncoding(String),
23 #[error("schema mismatch: {0}")]
25 SchemaMismatch(String),
26 #[error("invalid argument: {0}")]
28 InvalidArgument(String),
29 #[error("not supported: {0}")]
31 NotSupported(String),
32}
33
34impl From<NdError> for ArrowError {
35 fn from(error: NdError) -> Self {
36 match error {
37 NdError::Arrow(e) => e,
38 other => ArrowError::InvalidArgumentError(other.to_string()),
39 }
40 }
41}
42
43pub type Result<T, E = NdError> = std::result::Result<T, E>;
45
46macro_rules! nd_err {
47 ($variant:ident, $($arg:tt)*) => {
48 $crate::error::NdError::$variant(format!($($arg)*))
49 };
50}
51
52pub(crate) use nd_err;