Skip to main content

opencode_cloud_core/host/
error.rs

1//! Host-specific error types
2//!
3//! Errors that can occur during remote host operations.
4
5use thiserror::Error;
6
7/// Errors that can occur during host operations
8#[derive(Error, Debug)]
9pub enum HostError {
10    /// Failed to spawn SSH process
11    #[error("Failed to spawn SSH: {0}")]
12    SshSpawn(String),
13
14    /// SSH connection failed
15    #[error("SSH connection failed: {0}")]
16    ConnectionFailed(String),
17
18    /// SSH authentication failed (key not in agent, passphrase needed)
19    #[error("SSH authentication failed. Ensure your key is loaded: ssh-add {}", .key_hint.as_deref().unwrap_or("~/.ssh/id_rsa"))]
20    AuthFailed { key_hint: Option<String> },
21
22    /// Host not found in hosts.json
23    #[error("Host not found: {0}")]
24    NotFound(String),
25
26    /// Host already exists
27    #[error("Host already exists: {0}")]
28    AlreadyExists(String),
29
30    /// Failed to allocate local port for tunnel
31    #[error("Failed to allocate local port: {0}")]
32    PortAllocation(String),
33
34    /// Failed to load hosts file
35    #[error("Failed to load hosts file: {0}")]
36    LoadFailed(String),
37
38    /// Failed to save hosts file
39    #[error("Failed to save hosts file: {0}")]
40    SaveFailed(String),
41
42    /// Invalid host configuration
43    #[error("Invalid host configuration: {0}")]
44    InvalidConfig(String),
45
46    /// Tunnel connection timed out
47    #[error("SSH tunnel connection timed out after {0} attempts")]
48    TunnelTimeout(u32),
49
50    /// Remote Docker not available
51    #[error("Docker not available on remote host: {0}")]
52    RemoteDockerUnavailable(String),
53
54    /// Failed to read SSH config
55    #[error("Failed to read SSH config: {0}")]
56    SshConfigRead(String),
57
58    /// Failed to write SSH config
59    #[error("Failed to write SSH config: {0}")]
60    SshConfigWrite(String),
61}