Skip to content

Commit 787993c

Browse files
edfloreshzcyberphantom52
authored andcommitted
improv: error handling
1 parent 8eef5d2 commit 787993c

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/runner/mod.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,24 +22,26 @@ pub struct RunnerInfo {
2222

2323
impl RunnerInfo {
2424
// This fuction is only meant to be called by the runners themselves hence this is not public
25-
fn try_from(directory: &Path, executable: &Path) -> Result<Self, Box<dyn std::error::Error>> {
25+
fn try_from(directory: &Path, executable: &Path) -> Result<Self, Error> {
2626
if !directory.exists() {
27-
return Err(Box::new(std::io::Error::new(
27+
return Err(std::io::Error::new(
2828
std::io::ErrorKind::NotFound,
2929
format!("'{}' does not exist", directory.display()),
30-
)));
30+
)
31+
.into());
3132
}
3233
let full_path = directory.join(executable);
3334

3435
if !full_path.exists() || !full_path.is_file() {
35-
return Err(Box::new(Error::Io(std::io::Error::new(
36+
return Err(std::io::Error::new(
3637
std::io::ErrorKind::NotFound,
3738
format!(
3839
"Executable '{}' not found in directory '{}'",
3940
executable.display(),
4041
directory.display()
4142
),
42-
))));
43+
)
44+
.into());
4345
}
4446

4547
let name = directory
@@ -59,7 +61,7 @@ impl RunnerInfo {
5961
ver
6062
}
6163
})
62-
.map_err(|e| Error::Io(e))?;
64+
.map_err(Error::Io)?;
6365

6466
Ok(RunnerInfo {
6567
name,

0 commit comments

Comments
 (0)