summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRyan Geary <rtgnj42@gmail.com>2020-03-14 23:02:31 -0400
committerRyan Geary <rtgnj42@gmail.com>2020-03-14 23:02:31 -0400
commitb6d3e4ba5a4e714405cca6f66d9b0433abf74654 (patch)
tree0a956635116c3ea86df832c220fb11f77fe4de1b
parent94085bb302474128acbdbbe975ec415db0ee4003 (diff)
Add error messages for stdout writes
-rw-r--r--src/choice.rs10
-rw-r--r--src/main.rs7
2 files changed, 13 insertions, 4 deletions
diff --git a/src/choice.rs b/src/choice.rs
index b7bf879..80e0a8c 100644
--- a/src/choice.rs
+++ b/src/choice.rs
@@ -62,8 +62,14 @@ impl Choice {
}
fn write_bytes<WriterType: Write>(handle: &mut BufWriter<WriterType>, b: &[u8]) {
- handle.write(b).unwrap();
- handle.write(b" ").unwrap();
+ match handle.write(b) {
+ Ok(_) => (),
+ Err(e) => eprintln!("Failed to write to output: {}", e),
+ }
+ match handle.write(b" ") {
+ Ok(_) => (),
+ Err(e) => eprintln!("Failed to write to output: {}", e),
+ }
}
#[cfg_attr(feature = "flame_it", flame)]
diff --git a/src/main.rs b/src/main.rs
index 51f1b1f..551a572 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -28,9 +28,12 @@ fn main() {
for choice in &config.opt.choice {
choice.print_choice(&l, &config, &mut handle);
}
- handle.write(b"\n").unwrap();
+ match handle.write(b"\n") {
+ Ok(_) => (),
+ Err(e) => eprintln!("Failed to write to output: {}", e)
+ }
}
- Err(e) => println!("ERROR: {}", e),
+ Err(e) => println!("Failed to read line: {}", e),
}
}
}