waratah/error.rs
1//! Typed errors for the dev orchestrator CLI.
2
3use std::net::SocketAddr;
4
5use thiserror::Error;
6use waratah_compute::ComputeError;
7use waratah_router::RouterError;
8
9/// Failure starting or driving the local cluster.
10#[derive(Debug, Error)]
11pub enum DevError {
12 /// A storage-side binary could not be started.
13 #[error("could not spawn {program}: {source}")]
14 Spawn {
15 /// Path of the binary that failed to start.
16 program: String,
17 /// Underlying spawn failure.
18 source: std::io::Error,
19 },
20
21 /// A spawned process never accepted connections.
22 #[error("{process} did not start listening on {addr} in time")]
23 StartupTimeout {
24 /// Process name.
25 process: String,
26 /// Address it was asked to listen on.
27 addr: SocketAddr,
28 },
29
30 /// Static cluster configuration is missing an address or is malformed.
31 #[error(transparent)]
32 Config(#[from] RouterError),
33
34 /// The compute coordinator failed to connect, load, or query.
35 #[error(transparent)]
36 Compute(#[from] ComputeError),
37
38 /// Terminal or config I/O failure.
39 #[error(transparent)]
40 Io(#[from] std::io::Error),
41
42 /// A generic storage/config failure that has no dedicated variant
43 /// (malformed plugin config, lease misuse).
44 #[error("{0}")]
45 Backend(String),
46
47 /// `--http` value could not be parsed as a socket address.
48 #[error("invalid --http address {addr}: {source}")]
49 InvalidHttpAddr {
50 /// The address string from the CLI.
51 addr: String,
52 /// Parse failure.
53 source: std::net::AddrParseError,
54 },
55
56 /// `--notebooks-bind` / `notebooks.bind` could not be parsed.
57 #[error("invalid notebooks bind address {addr}: {source}")]
58 InvalidNotebooksBind {
59 /// The address string.
60 addr: String,
61 /// Parse failure.
62 source: std::net::AddrParseError,
63 },
64
65 /// `--with-notebooks` needs the HTTP server (kernels talk to the engine
66 /// over loopback HTTP like any other client).
67 #[error("--with-notebooks requires the HTTP server; drop --no-http")]
68 NotebooksWithoutHttp,
69
70 /// The notebook sidecar could not be validated, spawned, or supervised.
71 #[error(transparent)]
72 Notebooks(#[from] waratah_notebook::NotebookError),
73
74 /// `--with-ai` needs the HTTP server (the AI routes are HTTP routes).
75 #[error("--with-ai requires the HTTP server; drop --no-http")]
76 AiWithoutHttp,
77
78 /// AI configuration (`ai.toml`) is invalid.
79 #[error(transparent)]
80 Ai(#[from] waratah_api::AiConfigError),
81
82 /// `waratah stop` failed.
83 #[error("stop: {0}")]
84 DevStop(String),
85
86 /// Daemonized `waratah start` failed before or during startup.
87 #[error("daemon: {0}")]
88 Daemon(String),
89
90 /// The pidfile names a live cluster that this start does not own.
91 /// Overwriting it would leave that cluster unstoppable — `waratah
92 /// stop` resolves clusters through this exact file.
93 #[error(
94 "pidfile {path} names a live cluster (pid {pid}); refusing to start — stop that cluster first"
95 )]
96 PidfileInUse {
97 /// Pidfile that blocked the start.
98 path: std::path::PathBuf,
99 /// Live pid it names.
100 pid: u32,
101 },
102
103 /// `--direct-sst` is a stub until SstFileWriter ingest lands.
104 #[error("--direct-sst is not implemented")]
105 DirectSstNotImplemented,
106
107 /// A `waratah geo rebuild-index` step failed.
108 #[error("geo rebuild-index: {0}")]
109 GeoRebuild(String),
110
111 /// A `waratah temporal rebuild-index` step failed.
112 #[error("temporal rebuild-index: {0}")]
113 TemporalRebuild(String),
114
115 /// An offline hexastore write thread panicked.
116 #[error("offline hexastore write thread panicked on axis {axis}")]
117 OfflineWritePanic {
118 /// Axis whose OS thread panicked.
119 axis: &'static str,
120 },
121
122 /// Finished registry SST runs are still on disk. Deleting them would drop
123 /// the only copy of those dictionary entries.
124 #[error(
125 "refusing to delete {count} finished registry SST run(s) in {}; open the registry to ingest them",
126 dir.display()
127 )]
128 OfflineStagingNotRecovered {
129 /// Staging directory that still holds `run-*.sst` files.
130 dir: std::path::PathBuf,
131 /// How many finished runs were left.
132 count: usize,
133 },
134
135 /// The offline import's write failed, and flushing the finished chunks or
136 /// ingesting their registry runs failed as well.
137 #[error("offline import failed: {write}; {during}: {cleanup}")]
138 OfflineImportCleanup {
139 /// The write error that aborted the import.
140 write: String,
141 /// Which cleanup step failed.
142 during: &'static str,
143 /// The cleanup error.
144 cleanup: String,
145 },
146
147 /// Hexastore / registry storage failure on the offline path.
148 #[error(transparent)]
149 Storage(#[from] waratah_storage::StorageError),
150
151 /// In-process partition open or apply failed (`waratah standalone`).
152 #[error(transparent)]
153 Partition(#[from] waratah_partition::PartitionError),
154
155 /// In-process registry open or apply failed (`waratah standalone`).
156 #[error(transparent)]
157 Registry(#[from] waratah_registry::RegistryError),
158}