angular_switcher/
error.rs1use std::path::PathBuf;
2use thiserror::Error;
3
4#[derive(Debug, Error)]
5pub enum SwitcherError {
6 #[error("invalid input: {0}")]
7 Input(String),
8
9 #[error("no sibling found{}", match target {
10 Some(t) => format!(" for target '{t}'"),
11 None => String::new(),
12 })]
13 NoSibling { target: Option<String> },
14
15 #[error("config error: {0}")]
16 Config(String),
17
18 #[error("io error reading {path}: {source}")]
19 Io {
20 path: PathBuf,
21 #[source]
22 source: std::io::Error,
23 },
24
25 #[error("failed to launch `zed`: {0}. Is the Zed CLI on your PATH? See https://zed.dev/docs/getting-started")]
26 LaunchFailed(String),
27}
28
29impl SwitcherError {
30 pub fn exit_code(&self) -> i32 {
31 match self {
32 Self::Input(_) | Self::Io { .. } | Self::LaunchFailed(_) => 1,
33 Self::NoSibling { .. } => 2,
34 Self::Config(_) => 3,
35 }
36 }
37}