From ce270ba827ceb435b021c5055b6796d426ce7bdc Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Thu, 17 Sep 2020 00:21:20 +0200 Subject: main.rs: Print errors with prefix --- src/main.rs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/main.rs b/src/main.rs index 450b01b..cb3b77c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -17,7 +17,7 @@ fn main() { let matches = match opts.parse(&args[1..]) { Ok(m) => m, Err(e) => { - eprintln!("TODO {}", e); + eprintln(&e); process::exit(exitcode::NOINPUT); }, }; @@ -30,7 +30,7 @@ fn main() { match todos.master_tree() { Ok(t) => t, Err(e) => { - eprintln!("TODO {}", e); + eprintln(&e); process::exit(exitcode::USAGE); }, } @@ -41,7 +41,7 @@ fn main() { let oid = match repo.refname_to_id(&refname) { Ok(oid) => oid, Err(e) => { - eprintln!("TODO {}", e); + eprintln(&e); process::exit(exitcode::USAGE); }, }; @@ -49,7 +49,7 @@ fn main() { match repo.find_tree(oid) { Ok(t) => t, Err(e) => { - eprintln!("TODO {}", e); + eprintln(&e); process::exit(exitcode::USAGE); }, } @@ -57,3 +57,8 @@ fn main() { todos.write_since(tree, &mut std::io::stdout()).unwrap(); } + +/// Print to standard error with a program-specific prefix. +fn eprintln(error: &D) { + eprintln!("error: {}", error); +} -- cgit v1.2.3