microsandbox_agentd/error.rs
1//! Error types for the microsandbox-agentd crate.
2
3use thiserror::Error;
4
5//--------------------------------------------------------------------------------------------------
6// Types
7//--------------------------------------------------------------------------------------------------
8
9/// The result type for agentd operations.
10pub type AgentdResult<T> = Result<T, AgentdError>;
11
12/// Errors that can occur during agent daemon operations.
13#[derive(Debug, Error)]
14pub enum AgentdError {
15 /// An I/O error.
16 #[error("io error: {0}")]
17 Io(#[from] std::io::Error),
18
19 /// A protocol error.
20 #[error("protocol error: {0}")]
21 Protocol(#[from] microsandbox_protocol::ProtocolError),
22
23 /// A nix/libc error.
24 #[error("nix error: {0}")]
25 Nix(#[from] nix::Error),
26
27 /// A JSON serialization error.
28 #[error("json error: {0}")]
29 Json(#[from] serde_json::Error),
30
31 /// Failed to find the virtio serial port.
32 #[error("serial port not found: {0}")]
33 SerialPortNotFound(String),
34
35 /// An exec session error.
36 #[error("exec session error: {0}")]
37 ExecSession(String),
38
39 /// A spawn-time exec failure with classified payload, ready to
40 /// be shipped to the host as `ExecFailed`. Distinct from
41 /// `ExecSession` (which is a free-form internal error) — this
42 /// variant carries typed information the host can act on.
43 #[error("exec spawn failed: {}", .0.message)]
44 ExecSpawnFailed(microsandbox_protocol::exec::ExecFailed),
45
46 /// A config parse error at startup (malformed `MSB_*` env var).
47 #[error("config error: {0}")]
48 Config(String),
49
50 /// An init error.
51 #[error("init error: {0}")]
52 Init(String),
53
54 /// Graceful shutdown requested.
55 #[error("shutdown")]
56 Shutdown,
57}