nemo_flow_adaptive/
error.rs1use nemo_flow::plugin::PluginError;
7use thiserror::Error;
8
9#[derive(Debug, Error)]
11pub enum AdaptiveError {
12 #[error("invalid config: {0}")]
14 InvalidConfig(String),
15
16 #[error("not found: {0}")]
18 NotFound(String),
19
20 #[error("storage error: {0}")]
22 Storage(String),
23
24 #[error("serialization error: {0}")]
26 Serialization(serde_json::Error),
27
28 #[error("internal error: {0}")]
30 Internal(String),
31
32 #[error("registration failed: {0}")]
34 RegistrationFailed(String),
35
36 #[error("channel closed: {0}")]
38 ChannelClosed(String),
39
40 #[cfg(feature = "redis-backend")]
42 #[error("redis error: {0}")]
43 Redis(#[from] redis::RedisError),
44}
45
46impl From<serde_json::Error> for AdaptiveError {
47 fn from(value: serde_json::Error) -> Self {
48 Self::Serialization(value)
49 }
50}
51
52impl From<PluginError> for AdaptiveError {
53 fn from(value: PluginError) -> Self {
54 match value {
55 PluginError::InvalidConfig(message) => Self::InvalidConfig(message),
56 PluginError::NotFound(message) => Self::NotFound(message),
57 PluginError::Serialization(err) => Self::Serialization(err),
58 PluginError::Internal(message) => Self::Internal(message),
59 PluginError::RegistrationFailed(message) => Self::RegistrationFailed(message),
60 }
61 }
62}
63
64pub type Result<T> = std::result::Result<T, AdaptiveError>;
66
67#[cfg(test)]
68#[path = "../tests/coverage/error_tests.rs"]
69mod tests;