dora_node_api/error.rs
1use thiserror::Error;
2
3/// Typed errors for the Dora node API.
4#[derive(Debug, Error)]
5pub enum NodeError {
6 /// Initialization failed (config parsing, env vars, daemon handshake).
7 #[error("initialization failed: {0}")]
8 Init(String),
9 /// Sending an output or closing outputs failed.
10 #[error("output error: {0}")]
11 Output(String),
12 /// Data allocation or descriptor parsing failed.
13 #[error("data error: {0}")]
14 Data(String),
15 /// Catch-all for internal/unexpected errors (use `{:?}` for full chain).
16 #[error("internal error")]
17 Internal(#[from] eyre::Report),
18}
19
20/// Convenience alias used by all public node API functions.
21pub type NodeResult<T> = std::result::Result<T, NodeError>;
22
23/// Errors returned by the pattern-aware receive helpers on
24/// [`EventStream`](crate::EventStream).
25///
26/// These cover the recoverable failure modes a service client or action
27/// client needs to react to when waiting for a correlated reply. See
28/// [`EventStream::recv_service_response`](crate::EventStream::recv_service_response)
29/// and
30/// [`EventStream::recv_action_result`](crate::EventStream::recv_action_result).
31#[derive(Debug, Error)]
32pub enum PatternError {
33 /// The correlated reply did not arrive before the deadline elapsed.
34 #[error("pattern reply timed out")]
35 Timeout,
36 /// The expected server node restarted, so the in-flight correlation
37 /// is orphaned. Clients should retry the request against the new
38 /// instance (dora-rs/adora#148).
39 #[error("server `{0}` restarted while waiting for reply")]
40 ServerRestarted(String),
41 /// The event stream ended (e.g. dataflow stopping) before the
42 /// correlated reply arrived.
43 #[error("event stream ended before pattern reply arrived")]
44 StreamEnded,
45 /// The event stream surfaced an error while waiting.
46 #[error("pattern wait failed: {0}")]
47 StreamError(String),
48}