Remove trailing newlines in error messages (#8322)

This commit is contained in:
konsti 2024-10-18 17:17:41 +02:00 committed by GitHub
parent d296e7270a
commit 23c80c547c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 25 additions and 7 deletions

View file

@ -129,7 +129,7 @@ async fn main() -> ExitCode {
if let Err(err) = result { if let Err(err) = result {
eprintln!("{}", "uv-dev failed".red().bold()); eprintln!("{}", "uv-dev failed".red().bold());
for err in err.chain() { for err in err.chain() {
eprintln!(" {}: {}", "Caused by".red().bold(), err); eprintln!(" {}: {}", "Caused by".red().bold(), err.to_string().trim());
} }
ExitCode::FAILURE ExitCode::FAILURE
} else { } else {

View file

@ -299,11 +299,20 @@ async fn build_impl(
Err(err) => { Err(err) => {
let mut causes = err.chain(); 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))?; writeln!(printer.stderr(), "{}", source.annotate(&message))?;
for err in causes { for err in causes {
writeln!(printer.stderr(), " {}: {}", "Caused by".red().bold(), err)?; writeln!(
printer.stderr(),
" {}: {}",
"Caused by".red().bold(),
err.to_string().trim()
)?;
} }
} }
} }

View file

@ -235,7 +235,12 @@ pub(crate) async fn install(
key.green() key.green()
)?; )?;
for err in anyhow::Error::new(err).chain() { 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); return Ok(ExitStatus::Failure);

View file

@ -195,7 +195,7 @@ async fn do_uninstall(
printer.stderr(), printer.stderr(),
"Failed to uninstall {}: {}", "Failed to uninstall {}: {}",
key.green(), key.green(),
err err.to_string().trim()
)?; )?;
} }
return Ok(ExitStatus::Failure); return Ok(ExitStatus::Failure);

View file

@ -1629,9 +1629,13 @@ where
Ok(code) => code.into(), Ok(code) => code.into(),
Err(err) => { Err(err) => {
let mut causes = err.chain(); 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 { for err in causes {
eprintln!(" {}: {}", "Caused by".red().bold(), err); eprintln!(" {}: {}", "Caused by".red().bold(), err.to_string().trim());
} }
ExitStatus::Error.into() ExitStatus::Error.into()
} }