1#[cfg(feature = "python")]
2use pyo3::exceptions::PyRuntimeError;
3#[cfg(feature = "python")]
4use pyo3::PyErr;
5use thiserror::Error;
6
7#[derive(Error, Debug)]
9pub enum JsonRegisterError {
10 #[error("Database error: {0}")]
12 DbError(#[from] sqlx::Error),
13
14 #[error("Serialization error: {0}")]
16 SerdeError(#[from] serde_json::Error),
17
18 #[error("Configuration error: {0}")]
20 Configuration(String),
21
22 #[error("Runtime error: {0}")]
24 RuntimeError(String),
25
26 #[error("Python serialization error: {0}")]
28 SerializationError(String),
29}
30
31#[cfg(feature = "python")]
32impl From<JsonRegisterError> for PyErr {
33 fn from(err: JsonRegisterError) -> PyErr {
34 PyRuntimeError::new_err(err.to_string())
35 }
36}