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("Daemon already running (pid: {0})")]
21 DaemonAlreadyRunning(u32),
22
23 #[error("Daemon not running")]
24 DaemonNotRunning,
25
26 #[error("Failed to bind to address: {0}")]
27 BindError(String),
28
29 #[error("Port file not found: {0}")]
30 PortFileNotFound(PathBuf),
31
32 #[error("PID file not found: {0}")]
33 PidFileNotFound(PathBuf),
34
35 #[error("HTTP request error: {0}")]
36 HttpRequest(String),
37
38 #[error("Process spawn failed: {0}")]
39 ProcessSpawn(String),
40
41 #[error("Port range length ({range_len}) does not match node count ({count})")]
42 PortRangeMismatch { range_len: u16, count: u16 },
43
44 #[error("Binary not found at path: {0}")]
45 BinaryNotFound(PathBuf),
46
47 #[error("Binary resolution failed: {0}")]
48 BinaryResolution(String),
49
50 #[error("Invalid rewards address: {0}")]
51 InvalidRewardsAddress(String),
52
53 #[error("Failed to stop daemon: {0}")]
54 DaemonStopFailed(String),
55
56 #[error("Could not determine home directory (HOME/USERPROFILE not set)")]
57 HomeDirNotFound,
58
59 #[error("Update failed: {0}")]
60 UpdateFailed(String),
61
62 #[error("Failed to parse bootstrap_peers.toml: {0}")]
63 BootstrapConfigParse(String),
64
65 #[error("Node count {count} exceeds maximum of {max} per call")]
66 InvalidNodeCount { count: u16, max: u16 },
67
68 #[error(
69 "Cannot reset while nodes are running ({0} node(s) still running). Stop all nodes first."
70 )]
71 NodesStillRunning(u32),
72}
73
74pub type Result<T> = std::result::Result<T, Error>;