mirror of
https://github.com/astral-sh/uv.git
synced 2025-07-07 21:35:00 +00:00
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:
parent
471a1d657d
commit
cb29c89424
2 changed files with 8 additions and 3 deletions
|
@ -1,7 +1,7 @@
|
||||||
use std::fmt::Write;
|
use std::fmt::Write;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
use anyhow::Result;
|
use anyhow::{Context, Result};
|
||||||
use bitflags::bitflags;
|
use bitflags::bitflags;
|
||||||
use colored::Colorize;
|
use colored::Colorize;
|
||||||
use itertools::{Either, Itertools};
|
use itertools::{Either, Itertools};
|
||||||
|
@ -206,7 +206,8 @@ pub(crate) async fn sync(
|
||||||
|
|
||||||
let unzips = unzipper
|
let unzips = unzipper
|
||||||
.download(downloads, cache.unwrap_or(staging.path()))
|
.download(downloads, cache.unwrap_or(staging.path()))
|
||||||
.await?;
|
.await
|
||||||
|
.context("Failed to download and unpack wheels")?;
|
||||||
|
|
||||||
let s = if unzips.len() == 1 { "" } else { "s" };
|
let s = if unzips.len() == 1 { "" } else { "s" };
|
||||||
writeln!(
|
writeln!(
|
||||||
|
|
|
@ -159,7 +159,11 @@ async fn main() -> ExitCode {
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
#[allow(clippy::print_stderr)]
|
#[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()
|
ExitStatus::Error.into()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue