Skip to content

Commit

Permalink
Improve error handling in Coordinator (#48)
Browse files Browse the repository at this point in the history
  • Loading branch information
natalieesk committed Jul 19, 2023
1 parent 8453145 commit 3d574d8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion coordinator/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub fn cli(
"=== STEP 2: CHOOSE MESSAGE AND GENERATE COMMITMENT PACKAGE ===\n"
)?;

let signing_package = step_2(reader, logger, participants_config.participants.clone());
let signing_package = step_2(reader, logger, participants_config.participants.clone())?;

writeln!(logger, "=== STEP 3: BUILD GROUP SIGNATURE ===\n")?;

Expand Down
11 changes: 5 additions & 6 deletions coordinator/src/step_2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ pub fn step_2(
input: &mut impl BufRead,
logger: &mut dyn Write,
participants: Vec<Identifier>,
) -> SigningPackage {
let signing_package = request_inputs_commitments(input, logger, participants).unwrap();
) -> Result<SigningPackage, Box<dyn std::error::Error>> {
let signing_package = request_inputs_commitments(input, logger, participants)?;
print_commitments(logger, &signing_package);
signing_package
Ok(signing_package)
}

// Input required:
Expand All @@ -37,7 +37,7 @@ fn request_inputs_commitments(
let mut msg = String::new();
input.read_line(&mut msg)?;

let message = hex::decode(msg.trim()).unwrap(); //TODO: handle error
let message = hex::decode(msg.trim())?;

writeln!(logger, "The number of signers: ")?;

Expand All @@ -48,8 +48,7 @@ fn request_inputs_commitments(
logger,
"Please enter JSON encoded commitments for participant {:#?}:",
p
)
.unwrap(); // TODO: improve printing
)?; // TODO: improve printing

let mut commitments_input = String::new();
input.read_line(&mut commitments_input)?;
Expand Down

0 comments on commit 3d574d8

Please sign in to comment.