1 | use std::fmt;
|
2 |
|
3 | pub type Result<T> = std::result::Result<T, Error>;
|
4 |
|
5 | #[derive (Copy, Clone, Eq, PartialEq, Debug)]
|
6 | pub enum Error {
|
7 | /// An executable binary with that name was not found
|
8 | CannotFindBinaryPath,
|
9 | /// There was nowhere to search and the provided name wasn't an absolute path
|
10 | CannotGetCurrentDirAndPathListEmpty,
|
11 | /// Failed to canonicalize the path found
|
12 | CannotCanonicalize,
|
13 | }
|
14 |
|
15 | impl std::error::Error for Error {}
|
16 |
|
17 | impl fmt::Display for Error {
|
18 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
19 | match self {
|
20 | Error::CannotFindBinaryPath => write!(f, "cannot find binary path" ),
|
21 | Error::CannotGetCurrentDirAndPathListEmpty => write!(
|
22 | f,
|
23 | "no path to search and provided name is not an absolute path"
|
24 | ),
|
25 | Error::CannotCanonicalize => write!(f, "cannot canonicalize path" ),
|
26 | }
|
27 | }
|
28 | }
|
29 | |