Skip to main content

spatialrust_core/
error.rs

1use thiserror::Error;
2
3/// Result type used across SpatialRust crates.
4pub type SpatialResult<T> = Result<T, SpatialError>;
5
6/// Core error type for SpatialRust.
7#[derive(Debug, Error, PartialEq, Eq)]
8pub enum SpatialError {
9    /// A required field is missing from the point cloud schema.
10    #[error("missing required field: {0}")]
11    MissingField(String),
12
13    /// Schema validation failed.
14    #[error("schema validation failed: {0}")]
15    SchemaValidation(String),
16
17    /// Invalid argument supplied by the caller.
18    #[error("invalid argument: {0}")]
19    InvalidArgument(String),
20
21    /// IO-related error surfaced through higher-level crates.
22    #[error("io error: {0}")]
23    Io(String),
24
25    /// Buffer length does not match point cloud length.
26    #[error("buffer length mismatch: expected {expected}, found {found}")]
27    BufferLengthMismatch {
28        /// Expected number of elements.
29        expected: usize,
30        /// Actual number of elements.
31        found: usize,
32    },
33
34    /// Unsupported dtype for the requested operation.
35    #[error("unsupported dtype: {0:?}")]
36    UnsupportedDType(crate::DType),
37}