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