mirror of
https://github.com/cargo-bins/cargo-binstall.git
synced 2025-05-09 05:20:03 +00:00
Merge pull request #223 from NobodyXu/fix/join-err
Fix: join err handling, unify it using `BinstallError`
This commit is contained in:
commit
6964eee5d1
3 changed files with 17 additions and 14 deletions
23
src/main.rs
23
src/main.rs
|
@ -133,7 +133,6 @@ enum MainExit {
|
|||
Success(Duration),
|
||||
Error(BinstallError),
|
||||
Report(miette::Report),
|
||||
JoinErr(JoinError),
|
||||
}
|
||||
|
||||
impl Termination for MainExit {
|
||||
|
@ -149,11 +148,6 @@ impl Termination for MainExit {
|
|||
eprintln!("{err:?}");
|
||||
ExitCode::from(16)
|
||||
}
|
||||
Self::JoinErr(err) => {
|
||||
error!("Fatal error:");
|
||||
eprintln!("{err:?}");
|
||||
ExitCode::from(17)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -172,13 +166,16 @@ fn main() -> MainExit {
|
|||
let done = start.elapsed();
|
||||
debug!("run time: {done:?}");
|
||||
|
||||
result.map_or_else(MainExit::JoinErr, |res| {
|
||||
res.map(|_| MainExit::Success(done)).unwrap_or_else(|err| {
|
||||
err.downcast::<BinstallError>()
|
||||
.map(MainExit::Error)
|
||||
.unwrap_or_else(MainExit::Report)
|
||||
})
|
||||
})
|
||||
result.map_or_else(
|
||||
|join_err| MainExit::Error(BinstallError::from(join_err)),
|
||||
|res| {
|
||||
res.map(|_| MainExit::Success(done)).unwrap_or_else(|err| {
|
||||
err.downcast::<BinstallError>()
|
||||
.map(MainExit::Error)
|
||||
.unwrap_or_else(MainExit::Report)
|
||||
})
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
async fn entry(jobserver_client: LazyJobserverClient) -> Result<()> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue