reifydb_flow_operator_sdk/
error.rs1use std::fmt;
4
5#[derive(Debug)]
7pub enum FFIError {
8 Configuration(String),
10
11 StateError(String),
13
14 Serialization(String),
16
17 InvalidInput(String),
19
20 MemoryError(String),
22
23 Timeout,
25
26 NotImplemented(String),
28
29 Other(String),
31}
32
33impl fmt::Display for FFIError {
34 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
35 match self {
36 FFIError::Configuration(msg) => write!(f, "Configuration error: {}", msg),
37 FFIError::StateError(msg) => write!(f, "State error: {}", msg),
38 FFIError::Serialization(msg) => write!(f, "Serialization error: {}", msg),
39 FFIError::InvalidInput(msg) => write!(f, "Invalid input: {}", msg),
40 FFIError::MemoryError(msg) => write!(f, "Memory error: {}", msg),
41 FFIError::Timeout => write!(f, "Operation timeout"),
42 FFIError::NotImplemented(msg) => write!(f, "Not implemented: {}", msg),
43 FFIError::Other(msg) => write!(f, "{}", msg),
44 }
45 }
46}
47
48impl std::error::Error for FFIError {}
49
50impl From<FFIError> for reifydb_core::Error {
52 fn from(err: FFIError) -> Self {
53 use reifydb_type::{Error, internal};
54 Error(internal!(format!("{}", err)))
55 }
56}
57
58impl From<reifydb_core::Error> for FFIError {
60 fn from(err: reifydb_core::Error) -> Self {
61 FFIError::Other(err.to_string())
62 }
63}
64
65pub type Result<T, E = FFIError> = std::result::Result<T, E>;