Pretty-print errors

This commit is contained in:
Félix Saparelli 2022-05-31 23:01:12 +12:00
parent 02c8c0af00
commit 84ebc0039e
No known key found for this signature in database
GPG key ID: B948C4BAE44FC474
2 changed files with 17 additions and 13 deletions

View file

@ -1,7 +1,7 @@
use std::process::{ExitCode, Termination};
use log::warn;
use miette::Diagnostic;
use miette::{Report, Diagnostic};
use thiserror::Error;
/// Errors emitted by the library portion of cargo-binstall.
@ -182,12 +182,13 @@ impl BinstallError {
impl Termination for BinstallError {
fn report(self) -> ExitCode {
let code = self.exit_code();
if let BinstallError::UserAbort = self {
warn!("Installation cancelled");
} else {
eprintln!("{self:?}");
eprintln!("{:?}", Report::new(self));
}
self.exit_code()
code
}
}