Skip to main content

baked_potato/
error.rs

1use pyo3::exceptions::PyRuntimeError;
2use pyo3::PyErr;
3use thiserror::Error;
4use tracing::error;
5
6#[derive(Error, Debug)]
7pub enum MockError {
8    #[error("Error: {0}")]
9    Error(String),
10}
11
12impl From<MockError> for PyErr {
13    fn from(err: MockError) -> PyErr {
14        let msg = err.to_string();
15        error!("{}", msg);
16        PyRuntimeError::new_err(msg)
17    }
18}
19
20impl From<PyErr> for MockError {
21    fn from(err: PyErr) -> Self {
22        MockError::Error(err.to_string())
23    }
24}