mirror of
https://github.com/uutils/coreutils
synced 2024-12-13 23:02:38 +00:00
base64: Improve error handling
This commit is contained in:
parent
56f4c1e273
commit
d63c268239
1 changed files with 20 additions and 5 deletions
|
@ -53,7 +53,10 @@ fn decode(conf: &mut Conf) {
|
|||
out.write(bytes);
|
||||
out.flush();
|
||||
}
|
||||
Err(s) => fail!(s)
|
||||
Err(s) => {
|
||||
error!("error: {:s}", s);
|
||||
fail!()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -130,9 +133,13 @@ impl Conf {
|
|||
optflag("h", "help", "display this help text and exit"),
|
||||
optflag("V", "version", "output version information and exit")
|
||||
];
|
||||
// TODO: The user should get a clean error message in the case that
|
||||
// unwrap() fails.
|
||||
let matches = getopts(args.tail(), opts).unwrap();
|
||||
let matches = match getopts(args.tail(), opts) {
|
||||
Ok(m) => m,
|
||||
Err(e) => {
|
||||
error!("error: {:s}", e.to_err_msg());
|
||||
fail!()
|
||||
}
|
||||
};
|
||||
|
||||
Conf {
|
||||
progname: args[0].clone(),
|
||||
|
@ -149,7 +156,15 @@ impl Conf {
|
|||
},
|
||||
ignore_garbage: matches.opt_present("ignore-garbage"),
|
||||
line_wrap: match matches.opt_str("wrap") {
|
||||
Some(s) => from_str(s).unwrap(),
|
||||
Some(s) => match from_str(s) {
|
||||
Some(s) => s,
|
||||
None => {
|
||||
error!("error: {:s}",
|
||||
"Argument to option 'wrap' improperly "
|
||||
+ "formatted.");
|
||||
fail!()
|
||||
}
|
||||
},
|
||||
None => 76
|
||||
},
|
||||
input_file: if matches.free.is_empty()
|
||||
|
|
Loading…
Reference in a new issue