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