Skip to content

Commit 45fdbec

Browse files
konstinMtkN1
authored andcommitted
Remove trailing newlines in error messages (astral-sh#8322)
1 parent 0a210ab commit 45fdbec

File tree

5 files changed

+25
-7
lines changed

5 files changed

+25
-7
lines changed

crates/uv-dev/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ async fn main() -> ExitCode {
129129
if let Err(err) = result {
130130
eprintln!("{}", "uv-dev failed".red().bold());
131131
for err in err.chain() {
132-
eprintln!(" {}: {}", "Caused by".red().bold(), err);
132+
eprintln!(" {}: {}", "Caused by".red().bold(), err.to_string().trim());
133133
}
134134
ExitCode::FAILURE
135135
} else {

crates/uv/src/commands/build_frontend.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -299,11 +299,20 @@ async fn build_impl(
299299
Err(err) => {
300300
let mut causes = err.chain();
301301

302-
let message = format!("{}: {}", "error".red().bold(), causes.next().unwrap());
302+
let message = format!(
303+
"{}: {}",
304+
"error".red().bold(),
305+
causes.next().unwrap().to_string().trim()
306+
);
303307
writeln!(printer.stderr(), "{}", source.annotate(&message))?;
304308

305309
for err in causes {
306-
writeln!(printer.stderr(), " {}: {}", "Caused by".red().bold(), err)?;
310+
writeln!(
311+
printer.stderr(),
312+
" {}: {}",
313+
"Caused by".red().bold(),
314+
err.to_string().trim()
315+
)?;
307316
}
308317
}
309318
}

crates/uv/src/commands/python/install.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,12 @@ pub(crate) async fn install(
235235
key.green()
236236
)?;
237237
for err in anyhow::Error::new(err).chain() {
238-
writeln!(printer.stderr(), " {}: {}", "Caused by".red().bold(), err)?;
238+
writeln!(
239+
printer.stderr(),
240+
" {}: {}",
241+
"Caused by".red().bold(),
242+
err.to_string().trim()
243+
)?;
239244
}
240245
}
241246
return Ok(ExitStatus::Failure);

crates/uv/src/commands/python/uninstall.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ async fn do_uninstall(
195195
printer.stderr(),
196196
"Failed to uninstall {}: {}",
197197
key.green(),
198-
err
198+
err.to_string().trim()
199199
)?;
200200
}
201201
return Ok(ExitStatus::Failure);

crates/uv/src/lib.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1629,9 +1629,13 @@ where
16291629
Ok(code) => code.into(),
16301630
Err(err) => {
16311631
let mut causes = err.chain();
1632-
eprintln!("{}: {}", "error".red().bold(), causes.next().unwrap());
1632+
eprintln!(
1633+
"{}: {}",
1634+
"error".red().bold(),
1635+
causes.next().unwrap().to_string().trim()
1636+
);
16331637
for err in causes {
1634-
eprintln!(" {}: {}", "Caused by".red().bold(), err);
1638+
eprintln!(" {}: {}", "Caused by".red().bold(), err.to_string().trim());
16351639
}
16361640
ExitStatus::Error.into()
16371641
}

0 commit comments

Comments
 (0)