Better error reporting (#95)

The main change is to print the whole error chain. We can combine this
with adding `.context` to distinct phases to be able to locate crashes
without having to use a debugger.
This commit is contained in:
konsti 2023-10-16 04:15:10 +02:00 committed by GitHub
parent 471a1d657d
commit cb29c89424
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 3 deletions

View file

@ -1,7 +1,7 @@
use std::fmt::Write;
use std::path::Path;
use anyhow::Result;
use anyhow::{Context, Result};
use bitflags::bitflags;
use colored::Colorize;
use itertools::{Either, Itertools};
@ -206,7 +206,8 @@ pub(crate) async fn sync(
let unzips = unzipper
.download(downloads, cache.unwrap_or(staging.path()))
.await?;
.await
.context("Failed to download and unpack wheels")?;
let s = if unzips.len() == 1 { "" } else { "s" };
writeln!(

View file

@ -159,7 +159,11 @@ async fn main() -> ExitCode {
Err(err) => {
#[allow(clippy::print_stderr)]
{
eprintln!("{}: {}", "error".red().bold(), err);
let mut causes = err.chain();
eprintln!("{}: {}", "error".red().bold(), causes.next().unwrap());
for err in causes {
eprintln!(" {}: {}", "Caused by".red().bold(), err);
}
}
ExitStatus::Error.into()
}