improved error handling
This commit is contained in:
parent
6aff645392
commit
b79405b3c3
20
src/main.rs
20
src/main.rs
@ -118,16 +118,16 @@ fn format_arg(arg: String, settings: &mut Settings) -> String {
|
|||||||
|
|
||||||
fn write_as_unicode(string: String) {
|
fn write_as_unicode(string: String) {
|
||||||
let stdout = io::stdout();
|
let stdout = io::stdout();
|
||||||
stdout
|
if let Err(e) = stdout.lock().write_all(
|
||||||
.lock()
|
string
|
||||||
.write_all(
|
.chars()
|
||||||
string
|
.map(|c| c as u8)
|
||||||
.chars()
|
.collect::<Vec<u8>>()
|
||||||
.map(|c| c as u8)
|
.as_slice(),
|
||||||
.collect::<Vec<u8>>()
|
) {
|
||||||
.as_slice(),
|
eprintln!("error writing to stdout: {e}");
|
||||||
)
|
exit(1)
|
||||||
.map_or_else(|e| eprintln!("error writing to stdout: {e}"), |_| {});
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
Loading…
Reference in New Issue
Block a user