1use std::path::PathBuf;
2
3#[derive(Debug, thiserror::Error)]
4pub enum Error {
5 #[error("I/O error: {0}")]
6 Io(#[from] std::io::Error),
7
8 #[error("JSON serialization error: {0}")]
9 Json(#[from] serde_json::Error),
10
11 #[error("Node not found: {0}")]
12 NodeNotFound(u32),
13
14 #[error("Node already running: {0}")]
15 NodeAlreadyRunning(u32),
16
17 #[error("Node not running: {0}")]
18 NodeNotRunning(u32),
19
20 #[error("Node {0} has been evicted; its data directory was deleted to reclaim disk space. Dismiss it and add a new node instead of restarting.")]
21 NodeEvicted(u32),
22
23 #[error("Daemon already running (pid: {0})")]
24 DaemonAlreadyRunning(u32),
25
26 #[error("Daemon not running")]
27 DaemonNotRunning,
28
29 #[error("Failed to bind to address: {0}")]
30 BindError(String),
31
32 #[error("Port file not found: {0}")]
33 PortFileNotFound(PathBuf),
34
35 #[error("PID file not found: {0}")]
36 PidFileNotFound(PathBuf),
37
38 #[error("HTTP request error: {0}")]
39 HttpRequest(String),
40
41 #[error("Process spawn failed: {0}")]
42 ProcessSpawn(String),
43
44 #[error("Port range length ({range_len}) does not match node count ({count})")]
45 PortRangeMismatch { range_len: u16, count: u16 },
46
47 #[error("Binary not found at path: {0}")]
48 BinaryNotFound(PathBuf),
49
50 #[error("Binary resolution failed: {0}")]
51 BinaryResolution(String),
52
53 #[error("Invalid rewards address: {0}")]
54 InvalidRewardsAddress(String),
55
56 #[error("Failed to stop daemon: {0}")]
57 DaemonStopFailed(String),
58
59 #[error("Could not determine home directory (HOME/USERPROFILE not set)")]
60 HomeDirNotFound,
61
62 #[error("Update failed: {0}")]
63 UpdateFailed(String),
64
65 #[error("Failed to parse bootstrap_peers.toml: {0}")]
66 BootstrapConfigParse(String),
67
68 #[error("Node count {count} exceeds maximum of {max} per call")]
69 InvalidNodeCount { count: u16, max: u16 },
70
71 #[error(
72 "Cannot reset while nodes are running ({0} node(s) still running). Stop all nodes first."
73 )]
74 NodesStillRunning(u32),
75}
76
77pub type Result<T> = std::result::Result<T, Error>;