BlueGit

ict rusty-teams

Files

rusty-teams / crates / mcp / src / install / error.rs

error.rs

error.rs 831 B Download Raw
1use std::path::PathBuf;
2
3use super::Target;
4
5#[derive(Debug, thiserror::Error)]
6pub enum InstallError {
7 #[error("{} is not installed on this machine", .0.label())]
8 NotAvailable(Target),
9 #[error("cannot access {path}: {source}")]
10 Io {
11 path: PathBuf,
12 source: std::io::Error,
13 },
14 #[error("{path} is not valid: {message}")]
15 Malformed { path: PathBuf, message: String },
16}
17
18impl InstallError {
19 pub(super) fn io(path: &std::path::Path, source: std::io::Error) -> Self {
20 InstallError::Io {
21 path: path.to_path_buf(),
22 source,
23 }
24 }
25
26 pub(super) fn malformed(path: &std::path::Path, message: impl ToString) -> Self {
27 InstallError::Malformed {
28 path: path.to_path_buf(),
29 message: message.to_string(),
30 }
31 }
32}