-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moved everything back to main and implemented the error handling acco…
…rding to the std::process:Termination spec
- Loading branch information
1 parent
2737ab6
commit 27fc2f5
Showing
3 changed files
with
149 additions
and
125 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
use std::process::{ExitCode, Termination}; | ||
|
||
use tracing::error; | ||
|
||
pub enum Exit { | ||
Ok, | ||
Err(anyhow::Error), | ||
} | ||
|
||
impl Termination for Exit { | ||
fn report(self) -> ExitCode { | ||
match self { | ||
Exit::Ok => ExitCode::from(0), | ||
Exit::Err(err) => { | ||
error!("{}", err); | ||
err.chain() | ||
.skip(1) | ||
.for_each(|cause| error!("because: {}", cause)); | ||
|
||
ExitCode::from(1) | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters