Skip to main content

soma_fleet/
error.rs

1use crate::{HostId, RequestError, TopologyError, TopologyRevision};
2
3/// Fleet operation result using the shared error vocabulary.
4pub type FleetResult<T> = Result<T, FleetError>;
5
6/// Product-neutral fleet discovery, connection, command, and transfer failure.
7#[derive(Debug, Clone, PartialEq, Eq, thiserror::Error)]
8#[non_exhaustive]
9pub enum FleetError {
10    /// Topology contract validation failed.
11    #[error(transparent)]
12    Topology(#[from] TopologyError),
13    /// Request contract validation failed.
14    #[error(transparent)]
15    Request(#[from] RequestError),
16    /// A requested host did not exist in the current snapshot.
17    #[error("fleet target not found: {0}")]
18    TargetNotFound(HostId),
19    /// The caller bound work to an obsolete host revision.
20    #[error("stale topology for {host}: expected {expected}, current revision is {actual}")]
21    StaleTopology {
22        /// Host whose topology changed.
23        host: HostId,
24        /// Revision bound by the request or cached connection.
25        expected: TopologyRevision,
26        /// Current topology revision.
27        actual: TopologyRevision,
28    },
29    /// Cancellation was observed before completion.
30    #[error("fleet operation cancelled")]
31    Cancelled,
32    /// The absolute or per-target deadline elapsed.
33    #[error("fleet operation deadline exceeded")]
34    DeadlineExceeded,
35    /// A connection driver failed.
36    #[error("connection to {host} failed: {message}")]
37    Connection {
38        /// Failed host.
39        host: HostId,
40        /// Driver-safe diagnostic text.
41        message: String,
42    },
43    /// A command driver failed before returning a process result.
44    #[error("command on {host} failed: {message}")]
45    Command {
46        /// Failed host.
47        host: HostId,
48        /// Driver-safe diagnostic text.
49        message: String,
50    },
51    /// A post-spawn remote command was detached and may still be running.
52    #[error("remote command on {host} detached after {reason}; it may still be running")]
53    RemoteCommandDetached {
54        /// Remote target.
55        host: HostId,
56        /// Cancellation or deadline reason.
57        reason: &'static str,
58    },
59    /// A file transfer driver failed.
60    #[error("transfer from {source_host} to {destination_host} failed: {message}")]
61    Transfer {
62        /// Source host.
63        source_host: HostId,
64        /// Destination host.
65        destination_host: HostId,
66        /// Driver-safe diagnostic text.
67        message: String,
68    },
69    /// Transfer lifecycle accounting was invalid.
70    #[error("invalid transfer lifecycle: {0}")]
71    TransferLifecycle(String),
72    /// Event emission failed after the underlying action.
73    #[error("fleet event sink failed: {0}")]
74    EventSink(String),
75}
76
77#[cfg(test)]
78#[path = "error_tests.rs"]
79mod tests;