Commit a4c5db8
committed
refactor(error): route uncaught CLI errors through typed-error display
The typed-error classes in `utils/error/errors.mts` (AuthError, InputError,
ConfigError, NetworkError, FileSystemError, RateLimitError) plus the
matching `formatErrorForDisplay`/`formatErrorForTerminal`/`formatErrorForJson`
helpers were only ever exercised by tests — the CLI entry point used its
own inline `if/else` dispatch that handled AuthError/InputError/Error.
- Replace the inline dispatch in `cli-entry.mts` with calls to
`formatErrorForTerminal` and `formatErrorForJson`, so any typed error
now thrown in production gets consistent titles, recovery suggestions,
and JSON/text formatting.
- Convert `queryApi`'s "Socket API base URL is not configured" throw from
a generic Error to a ConfigError keyed on CONFIG_KEY_API_BASE_URL. Users
now see recovery suggestions directing them to `socket config set`
instead of a bare stack trace.
The remaining typed classes (NetworkError, FileSystemError, RateLimitError)
stay parked. Forcing them into current CResult-returning sites would be a
larger refactor and isn't needed for the display wiring itself to work —
they slot in automatically the moment any throw site adopts them.1 parent 64a14c5 commit a4c5db8
2 files changed
+12
-36
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
31 | | - | |
32 | 31 | | |
33 | 32 | | |
34 | 33 | | |
| |||
53 | 52 | | |
54 | 53 | | |
55 | 54 | | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
61 | 59 | | |
62 | 60 | | |
63 | 61 | | |
| |||
181 | 179 | | |
182 | 180 | | |
183 | 181 | | |
184 | | - | |
185 | | - | |
186 | | - | |
187 | | - | |
188 | | - | |
189 | | - | |
190 | | - | |
191 | | - | |
192 | | - | |
193 | | - | |
194 | | - | |
195 | | - | |
196 | | - | |
197 | | - | |
198 | | - | |
199 | | - | |
200 | | - | |
201 | | - | |
202 | 182 | | |
203 | 183 | | |
204 | 184 | | |
| |||
213 | 193 | | |
214 | 194 | | |
215 | 195 | | |
216 | | - | |
217 | | - | |
218 | | - | |
219 | | - | |
220 | | - | |
221 | | - | |
222 | | - | |
| 196 | + | |
223 | 197 | | |
224 | 198 | | |
225 | 199 | | |
226 | | - | |
227 | | - | |
228 | | - | |
229 | | - | |
| 200 | + | |
| 201 | + | |
230 | 202 | | |
231 | 203 | | |
232 | 204 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
| 58 | + | |
58 | 59 | | |
59 | 60 | | |
60 | 61 | | |
| |||
383 | 384 | | |
384 | 385 | | |
385 | 386 | | |
386 | | - | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
387 | 391 | | |
388 | 392 | | |
389 | 393 | | |
| |||
0 commit comments