Skip to main content

scouter_types/dataset/
error.rs

1use pyo3::exceptions::PyRuntimeError;
2use pyo3::PyErr;
3use thiserror::Error;
4
5#[derive(Error, Debug)]
6pub enum DatasetError {
7    #[error("Schema parse error: {0}")]
8    SchemaParseError(String),
9
10    #[error("Unsupported JSON Schema type: {0}")]
11    UnsupportedType(String),
12
13    #[error("Failed to resolve $ref: {0}")]
14    RefResolutionError(String),
15
16    #[error("Schema fingerprint mismatch — expected {expected}, got {actual}")]
17    FingerprintMismatch { expected: String, actual: String },
18
19    #[error(transparent)]
20    SerializationError(#[from] serde_json::Error),
21
22    #[error("Arrow schema serialization error: {0}")]
23    ArrowSchemaError(String),
24
25    #[error("{0}")]
26    PyError(String),
27}
28
29impl From<DatasetError> for PyErr {
30    fn from(err: DatasetError) -> PyErr {
31        let msg = err.to_string();
32        PyRuntimeError::new_err(msg)
33    }
34}
35
36impl From<PyErr> for DatasetError {
37    fn from(err: PyErr) -> DatasetError {
38        DatasetError::PyError(err.to_string())
39    }
40}