improved error handling

This commit is contained in:
Lu 2023-07-02 14:47:09 +02:00
parent 6aff645392
commit b79405b3c3

View File

@ -118,16 +118,16 @@ fn format_arg(arg: String, settings: &mut Settings) -> String {
fn write_as_unicode(string: String) {
let stdout = io::stdout();
stdout
.lock()
.write_all(
if let Err(e) = stdout.lock().write_all(
string
.chars()
.map(|c| c as u8)
.collect::<Vec<u8>>()
.as_slice(),
)
.map_or_else(|e| eprintln!("error writing to stdout: {e}"), |_| {});
) {
eprintln!("error writing to stdout: {e}");
exit(1)
}
}
fn main() {