-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy patherror.rs
53 lines (46 loc) · 1.32 KB
/
error.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
use std::convert::From;
use std::num::TryFromIntError;
#[derive(Debug, thiserror::Error)]
pub enum MiscKind {
/// Error when checking out a specific tag or commit in a particular repo
/// used when generating test suites
#[error("git error: `git {arg_string}`")]
Git { arg_string: String },
}
#[derive(Debug, thiserror::Error)]
pub enum Error {
#[error("{0}")]
Io(std::io::Error),
#[error("given path to `rust` does not exist: {0}")]
NoRust(std::path::PathBuf),
#[error("given path to `gccrs` does not exist: {0}")]
NoGccrs(std::path::PathBuf),
#[error("{0}")]
PathPrefix(std::path::StripPrefixError),
#[error("{0}")]
WalkDir(walkdir::Error),
#[error("{0}")]
Misc(MiscKind),
#[error("invalid exit code: expected value to fit in `u8`: {0}")]
ExitCodeConversion(TryFromIntError),
}
impl From<std::io::Error> for Error {
fn from(e: std::io::Error) -> Self {
Error::Io(e)
}
}
impl From<std::path::StripPrefixError> for Error {
fn from(e: std::path::StripPrefixError) -> Self {
Error::PathPrefix(e)
}
}
impl From<walkdir::Error> for Error {
fn from(e: walkdir::Error) -> Self {
Error::WalkDir(e)
}
}
impl From<TryFromIntError> for Error {
fn from(e: TryFromIntError) -> Self {
Error::ExitCodeConversion(e)
}
}