Skip to content

Commit

Permalink
Remove trailing newlines in error messages (astral-sh#8322)
Browse files Browse the repository at this point in the history
  • Loading branch information
konstin authored Oct 18, 2024
1 parent d296e72 commit 23c80c5
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 7 deletions.
2 changes: 1 addition & 1 deletion crates/uv-dev/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ async fn main() -> ExitCode {
if let Err(err) = result {
eprintln!("{}", "uv-dev failed".red().bold());
for err in err.chain() {
eprintln!(" {}: {}", "Caused by".red().bold(), err);
eprintln!(" {}: {}", "Caused by".red().bold(), err.to_string().trim());
}
ExitCode::FAILURE
} else {
Expand Down
13 changes: 11 additions & 2 deletions crates/uv/src/commands/build_frontend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -299,11 +299,20 @@ async fn build_impl(
Err(err) => {
let mut causes = err.chain();

let message = format!("{}: {}", "error".red().bold(), causes.next().unwrap());
let message = format!(
"{}: {}",
"error".red().bold(),
causes.next().unwrap().to_string().trim()
);
writeln!(printer.stderr(), "{}", source.annotate(&message))?;

for err in causes {
writeln!(printer.stderr(), " {}: {}", "Caused by".red().bold(), err)?;
writeln!(
printer.stderr(),
" {}: {}",
"Caused by".red().bold(),
err.to_string().trim()
)?;
}
}
}
Expand Down
7 changes: 6 additions & 1 deletion crates/uv/src/commands/python/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,12 @@ pub(crate) async fn install(
key.green()
)?;
for err in anyhow::Error::new(err).chain() {
writeln!(printer.stderr(), " {}: {}", "Caused by".red().bold(), err)?;
writeln!(
printer.stderr(),
" {}: {}",
"Caused by".red().bold(),
err.to_string().trim()
)?;
}
}
return Ok(ExitStatus::Failure);
Expand Down
2 changes: 1 addition & 1 deletion crates/uv/src/commands/python/uninstall.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ async fn do_uninstall(
printer.stderr(),
"Failed to uninstall {}: {}",
key.green(),
err
err.to_string().trim()
)?;
}
return Ok(ExitStatus::Failure);
Expand Down
8 changes: 6 additions & 2 deletions crates/uv/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1629,9 +1629,13 @@ where
Ok(code) => code.into(),
Err(err) => {
let mut causes = err.chain();
eprintln!("{}: {}", "error".red().bold(), causes.next().unwrap());
eprintln!(
"{}: {}",
"error".red().bold(),
causes.next().unwrap().to_string().trim()
);
for err in causes {
eprintln!(" {}: {}", "Caused by".red().bold(), err);
eprintln!(" {}: {}", "Caused by".red().bold(), err.to_string().trim());
}
ExitStatus::Error.into()
}
Expand Down

0 comments on commit 23c80c5

Please sign in to comment.