mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 11:37:44 +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.write(bytes);
|
||||||
out.flush();
|
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("h", "help", "display this help text and exit"),
|
||||||
optflag("V", "version", "output version information and exit")
|
optflag("V", "version", "output version information and exit")
|
||||||
];
|
];
|
||||||
// TODO: The user should get a clean error message in the case that
|
let matches = match getopts(args.tail(), opts) {
|
||||||
// unwrap() fails.
|
Ok(m) => m,
|
||||||
let matches = getopts(args.tail(), opts).unwrap();
|
Err(e) => {
|
||||||
|
error!("error: {:s}", e.to_err_msg());
|
||||||
|
fail!()
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
Conf {
|
Conf {
|
||||||
progname: args[0].clone(),
|
progname: args[0].clone(),
|
||||||
|
@ -149,7 +156,15 @@ impl Conf {
|
||||||
},
|
},
|
||||||
ignore_garbage: matches.opt_present("ignore-garbage"),
|
ignore_garbage: matches.opt_present("ignore-garbage"),
|
||||||
line_wrap: match matches.opt_str("wrap") {
|
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
|
None => 76
|
||||||
},
|
},
|
||||||
input_file: if matches.free.is_empty()
|
input_file: if matches.free.is_empty()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue