Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove trailing newlines in error messages #8322

Merged
merged 1 commit into from
Oct 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading