mirror of
https://github.com/atuinsh/atuin.git
synced 2025-06-25 04:11:53 +02:00
fix: Check for format errors when printing history (#1623)
The runtime formatting used to list history commands can fail in its Display implementation and the error is not propagated through to the write error it causes. Instead, the error is cached in the FormatArgs being printed. It's a bit clumsy but by checking if there's a cached error, we can get a more useful error for the user. eg, atuin search cargo --format '{invalid}' gives history output failed with: The requested key "invalid" is unknown instead of history output failed with: formatter error
This commit is contained in:
parent
079a078fdb
commit
400e1ba23d
@ -152,7 +152,12 @@ pub fn print_list(
|
|||||||
for h in iterator {
|
for h in iterator {
|
||||||
let fh = FmtHistory(h, CmdFormat::for_output(&w));
|
let fh = FmtHistory(h, CmdFormat::for_output(&w));
|
||||||
let args = parsed_fmt.with_args(&fh);
|
let args = parsed_fmt.with_args(&fh);
|
||||||
check_for_write_errors(write!(w, "{args}{entry_terminator}"));
|
let write = write!(w, "{args}{entry_terminator}");
|
||||||
|
if let Err(err) = args.status() {
|
||||||
|
eprintln!("ERROR: history output failed with: {err}");
|
||||||
|
std::process::exit(1);
|
||||||
|
}
|
||||||
|
check_for_write_errors(write);
|
||||||
if flush_each_line {
|
if flush_each_line {
|
||||||
check_for_write_errors(w.flush());
|
check_for_write_errors(w.flush());
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user