rohas_runtime/
error.rs

1use thiserror::Error;
2
3pub type Result<T> = std::result::Result<T, RuntimeError>;
4
5#[derive(Error, Debug)]
6pub enum RuntimeError {
7    #[error("Handler execution failed: {0}")]
8    ExecutionFailed(String),
9
10    #[error("Handler not found: {0}")]
11    HandlerNotFound(String),
12
13    #[error("Timeout: handler exceeded {0} seconds")]
14    Timeout(u64),
15
16    #[error("Serialization error: {0}")]
17    Serialization(#[from] serde_json::Error),
18
19    #[error("IO error: {0}")]
20    Io(#[from] std::io::Error),
21
22    #[error("Python error: {0}")]
23    PythonError(String),
24
25    #[error("Node.js error: {0}")]
26    NodeError(String),
27
28    #[error("Invalid handler response: {0}")]
29    InvalidResponse(String),
30}
31
32// Implement conversion from pyo3::PyErr
33impl From<pyo3::PyErr> for RuntimeError {
34    fn from(err: pyo3::PyErr) -> Self {
35        RuntimeError::PythonError(err.to_string())
36    }
37}