1use thiserror::Error;
2
3pub type Result<T> = std::result::Result<T, Error>;
4
5#[derive(Debug, Error)]
6pub enum Error {
7 #[error(
8 "Unable to find {binary} to execute. Run `monger get {version}` and try again if you're \
9 sure the version and binary name are correct"
10 )]
11 BinaryNotFound { binary: String, version: String },
12
13 #[error(
14 "A mongodb version with the id '{id}' already exists. Either pass --force to overwrite it \
15 or pass a different id."
16 )]
17 ExistingId { id: String },
18
19 #[error("`{command}` command failed")]
20 FailedSubprocess {
21 command: String,
22 exit_code: Option<i32>,
23 },
24
25 #[error("An HTTP error occurred: {inner}")]
26 Http {
27 #[from]
28 inner: reqwest::Error,
29 },
30
31 #[error("HTML response from {url} did not match expected structure")]
32 InvalidHtml { url: String },
33
34 #[error("HTTP error occurred when trying to access url '{url}'")]
35 InvalidUrl { url: String },
36
37 #[error("MongoDB version {version} does not exist")]
38 InvalidVersion { version: String },
39
40 #[error("An I/O error occurred: {inner}")]
41 Io {
42 #[from]
43 inner: std::io::Error,
44 },
45
46 #[error("Unable to determine the OS release version")]
47 OsRelease {
48 #[from]
49 inner: rs_release::OsReleaseError,
50 },
51
52 #[error("Unable to parse semantic version")]
53 SemVer {
54 #[from]
55 inner: semver::SemVerError,
56 },
57
58 #[error("Unable to convert HTTP header to string: {inner}")]
59 ToStr {
60 #[from]
61 inner: reqwest::header::ToStrError,
62 },
63
64 #[error("Unable to find home directory")]
65 UnknownHomeDirectory,
66
67 #[error("Unable to identify operating system")]
68 UnknownOs,
69
70 #[error("{os_name} is unsupported")]
71 UnsupportedOs { os_name: String },
72
73 #[error("Unable to find version {version}")]
74 VersionNotFound { version: String },
75}