mirror of
https://github.com/nivekuil/rip
synced 2024-11-10 06:04:17 +00:00
Use stderr for errors
This commit is contained in:
parent
415fd4288c
commit
3bd5513b77
2 changed files with 10 additions and 4 deletions
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "rm-improved"
|
||||
version = "0.11.2"
|
||||
version = "0.11.3"
|
||||
authors = ["mail@nivekuil.com"]
|
||||
description = "rip: a safe and ergonomic alternative to rm"
|
||||
repository = "https://github.com/nivekuil/rip"
|
||||
|
|
12
src/main.rs
12
src/main.rs
|
@ -41,14 +41,20 @@ struct RecordItem<'a> {
|
|||
|
||||
fn main() {
|
||||
if let Err(ref e) = run() {
|
||||
println!("Error: {}", e);
|
||||
use ::std::io::Write;
|
||||
let stderr = &mut ::std::io::stderr();
|
||||
let errmsg = "Error writing to stderr";
|
||||
|
||||
writeln!(stderr, "error: {}", e).expect(errmsg);
|
||||
|
||||
for e in e.iter().skip(1) {
|
||||
println!("Caused by: {}", e);
|
||||
writeln!(stderr, "caused by: {}", e).expect(errmsg);
|
||||
}
|
||||
|
||||
// The backtrace is not always generated. Try to run this example
|
||||
// with `RUST_BACKTRACE=1`.
|
||||
if let Some(backtrace) = e.backtrace() {
|
||||
println!("Backtrace: {:?}", backtrace);
|
||||
writeln!(stderr, "backtrace: {:?}", backtrace).expect(errmsg);
|
||||
}
|
||||
|
||||
::std::process::exit(1);
|
||||
|
|
Loading…
Reference in a new issue