Simplify error handling: bubble up immediately
@@ -315,24 +315,8 @@ fn sub_pkg_hash(m: &ArgMatches) -> Result<()> {
// read files from stdin
let stdin = io::stdin();
for line in stdin.lock().lines() {
- match line {
- Ok(line) => {
- let file = line.trim_right();
- if Path::new(&file).is_file() {
- match command::pkg::hash::start(&file) {
- Ok(_) => (),
- Err(error) => {
- writeln!(io::stderr(), "{}: error hashing file: {}", &file, error).unwrap();
- }
- }
- } else {
- writeln!(io::stderr(), "{}: No such file or directory", &file).unwrap();
- }
- },
- Err(error) => {
- writeln!(io::stderr(), "error: {}", error).unwrap();
- },
- }
+ let file = line.unwrap();
+ try!(command::pkg::hash::start(file.trim_right()));
}
Ok(())
},
