Commit 2f92ac7
committed
refactor(global-cli): use #[from] PmCli + is_user_message() helper
Replace the explicit per-variant `From<vite_pm_cli::Error>` impl
(remapping UserMessage/Install/Workspace/etc. one-by-one) with an
`#[error(transparent)] PmCli(#[from] vite_pm_cli::Error)` variant and
an `Error::is_user_message()` helper that knows about both the
top-level `UserMessage(_)` and the wrapped `PmCli(UserMessage(_))`.
This drops the 12-line manual match in error.rs, localizes the
"is friendly message" semantic on `Error` itself instead of leaking
variant matches into main.rs, and makes adding future sub-error crates
a one-line change to `is_user_message`.
Also switch the two `eprintln!("{e}")` calls in main.rs that print
user-facing messages to `output::raw_stderr` for consistency with the
rest of the codebase's "go through `output::*` instead of raw print
macros" rule.1 parent ec1e361 commit 2f92ac7
2 files changed
Lines changed: 12 additions & 17 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
67 | 70 | | |
68 | 71 | | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
82 | 77 | | |
83 | 78 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
196 | 196 | | |
197 | 197 | | |
198 | 198 | | |
199 | | - | |
200 | | - | |
| 199 | + | |
| 200 | + | |
201 | 201 | | |
202 | 202 | | |
203 | 203 | | |
| |||
395 | 395 | | |
396 | 396 | | |
397 | 397 | | |
398 | | - | |
399 | | - | |
| 398 | + | |
| 399 | + | |
400 | 400 | | |
401 | 401 | | |
402 | 402 | | |
| |||
0 commit comments