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 /// An init error.
40 #[error("init error: {0}")]
41 Init(String),
42
43 /// Graceful shutdown requested.
44 #[error("shutdown")]
45 Shutdown,
46}