Make error handling more semantic in main (#326)
This commit is contained in:
parent
9493bc97a3
commit
ad3c31588b
27
src/main.rs
27
src/main.rs
|
@ -15,12 +15,9 @@ use crate::trusted_dealer_keygen::trusted_dealer_keygen;
|
||||||
fn main() -> io::Result<()> {
|
fn main() -> io::Result<()> {
|
||||||
let mut reader = Box::new(io::stdin().lock());
|
let mut reader = Box::new(io::stdin().lock());
|
||||||
let config = request_inputs(&mut reader);
|
let config = request_inputs(&mut reader);
|
||||||
match config {
|
if let Err(e) = config {
|
||||||
Ok(_) => (),
|
eprintln!("Error: {}", e);
|
||||||
Err(e) => {
|
std::process::exit(exitcode::DATAERR)
|
||||||
eprintln!("Error: {}", e);
|
|
||||||
std::process::exit(exitcode::DATAERR)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let config = config.unwrap();
|
let config = config.unwrap();
|
||||||
|
@ -28,22 +25,16 @@ fn main() -> io::Result<()> {
|
||||||
let mut rng = thread_rng();
|
let mut rng = thread_rng();
|
||||||
|
|
||||||
let valid = validate_inputs(&config);
|
let valid = validate_inputs(&config);
|
||||||
match valid {
|
if let Err(e) = valid {
|
||||||
Ok(_) => (),
|
eprintln!("Error: {}", e);
|
||||||
Err(e) => {
|
std::process::exit(exitcode::DATAERR)
|
||||||
eprintln!("Error: {}", e);
|
|
||||||
std::process::exit(exitcode::DATAERR)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Print outputs
|
// Print outputs
|
||||||
let out = trusted_dealer_keygen(config, &mut rng);
|
let out = trusted_dealer_keygen(config, &mut rng);
|
||||||
match out {
|
if let Err(e) = out {
|
||||||
Ok(_) => (),
|
eprintln!("Error: {}", e);
|
||||||
Err(e) => {
|
std::process::exit(1)
|
||||||
eprintln!("Error: {}", e);
|
|
||||||
std::process::exit(1)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let (key_packages, pubkeys) = out.unwrap();
|
let (key_packages, pubkeys) = out.unwrap();
|
||||||
|
|
Loading…
Reference in New Issue