From bd65cb53b558fa01ec2323163d14387578b53bd2 Mon Sep 17 00:00:00 2001 From: Richa Jain Date: Fri, 13 Sep 2024 19:06:11 +0800 Subject: [PATCH] Fixing test --- ipa-core/src/cli/crypto.rs | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/ipa-core/src/cli/crypto.rs b/ipa-core/src/cli/crypto.rs index a195fef89..84871776a 100644 --- a/ipa-core/src/cli/crypto.rs +++ b/ipa-core/src/cli/crypto.rs @@ -180,7 +180,7 @@ pub async fn decrypt_and_reconstruct(args: DecryptArgs) -> Result<(), BoxError> .create_new(true) .open(args.output_file)?, ); - let mut first_error = None; + let mut first_error = Ok(()); for (idx, (dec_report1, (dec_report2, dec_report3))) in decrypted_reports1 .zip(decrypted_reports2.zip(decrypted_reports3)) .enumerate() @@ -236,33 +236,33 @@ pub async fn decrypt_and_reconstruct(args: DecryptArgs) -> Result<(), BoxError> trigger_value, )?; } + // error handling in case decryption failed (Err(e1), _, _) => { writeln!(writer, "Decryption failed Record: {idx} Reason:{e1}",)?; eprintln!("Decryption failed Record: {idx} Reason:{e1}"); - if first_error.is_none() { - first_error = Some(e1); + if first_error.is_ok() { + first_error = Err(e1); } } (Ok(_), Err(e2), _) => { writeln!(writer, "Decryption failed Record: {idx} Reason:{e2}",)?; eprintln!("Decryption failed Record: {idx} Reason:{e2}"); - if first_error.is_none() { - first_error = Some(e2); + if first_error.is_ok() { + first_error = Err(e2); } } (Ok(_), Ok(_), Err(e3)) => { writeln!(writer, "Decryption failed Record: {idx} Reason:{e3}",)?; eprintln!("Decryption failed Record: {idx} Reason:{e3}"); - if first_error.is_none() { - first_error = Some(e3); + if first_error.is_ok() { + first_error = Err(e3); } } } } - match first_error { - None => Ok(()), - Some(err) => Err(Box::new(err)), - } + + first_error.unwrap(); + Ok(()) } #[cfg(test)]