asimov_module/resolve/
error.rs1use alloc::string::String;
4
5#[cfg(feature = "std")]
6#[derive(Debug, thiserror::Error)]
7pub enum FromDirError {
8 #[error("failed to read manifest directory `{path}`: {source}")]
9 ManifestDirIo {
10 path: std::path::PathBuf,
11 #[source]
12 source: std::io::Error,
13 },
14 #[error("failed to read manifest file `{path}`: {source}")]
15 ManifestIo {
16 path: std::path::PathBuf,
17 #[source]
18 source: std::io::Error,
19 },
20 #[cfg(feature = "yaml")]
21 #[error("failed to parse manifest file `{path}`: {source}")]
22 Parse {
23 path: std::path::PathBuf,
24 #[source]
25 source: serde_yml::Error,
26 },
27 #[error("failed to add manifest file `{path}` to resolver: {source}")]
28 Insert {
29 path: std::path::PathBuf,
30 #[source]
31 source: UrlParseError,
32 },
33}
34
35#[cfg(all(feature = "cli", feature = "std"))]
36impl From<FromDirError> for clientele::SysexitsError {
37 fn from(value: FromDirError) -> Self {
38 use FromDirError::*;
39 use clientele::SysexitsError::*;
40 match value {
41 ManifestDirIo { .. } => EX_IOERR,
42 ManifestIo { .. } => EX_IOERR,
43 #[cfg(feature = "yaml")]
44 Parse { .. } => EX_CONFIG,
45 Insert { source, .. } => source.into(),
46 }
47 }
48}
49
50#[derive(Clone, Debug, thiserror::Error)]
51pub enum UrlParseError {
52 #[error("URL can't be empty")]
53 EmptyUrl,
54 #[error("invalid URL `{url}`: {source}")]
55 InvalidUrl {
56 url: String,
57 #[source]
58 source: url::ParseError,
59 },
60}
61
62#[cfg(all(feature = "cli", feature = "std"))]
63impl From<UrlParseError> for clientele::SysexitsError {
64 fn from(_value: UrlParseError) -> Self {
65 clientele::SysexitsError::EX_USAGE
66 }
67}