Skip to content

Commit bd65cb5

Browse files
committed
Fixing test
1 parent 9baca44 commit bd65cb5

1 file changed

Lines changed: 11 additions & 11 deletions

File tree

ipa-core/src/cli/crypto.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ pub async fn decrypt_and_reconstruct(args: DecryptArgs) -> Result<(), BoxError>
180180
.create_new(true)
181181
.open(args.output_file)?,
182182
);
183-
let mut first_error = None;
183+
let mut first_error = Ok(());
184184
for (idx, (dec_report1, (dec_report2, dec_report3))) in decrypted_reports1
185185
.zip(decrypted_reports2.zip(decrypted_reports3))
186186
.enumerate()
@@ -236,33 +236,33 @@ pub async fn decrypt_and_reconstruct(args: DecryptArgs) -> Result<(), BoxError>
236236
trigger_value,
237237
)?;
238238
}
239+
// error handling in case decryption failed
239240
(Err(e1), _, _) => {
240241
writeln!(writer, "Decryption failed Record: {idx} Reason:{e1}",)?;
241242
eprintln!("Decryption failed Record: {idx} Reason:{e1}");
242-
if first_error.is_none() {
243-
first_error = Some(e1);
243+
if first_error.is_ok() {
244+
first_error = Err(e1);
244245
}
245246
}
246247
(Ok(_), Err(e2), _) => {
247248
writeln!(writer, "Decryption failed Record: {idx} Reason:{e2}",)?;
248249
eprintln!("Decryption failed Record: {idx} Reason:{e2}");
249-
if first_error.is_none() {
250-
first_error = Some(e2);
250+
if first_error.is_ok() {
251+
first_error = Err(e2);
251252
}
252253
}
253254
(Ok(_), Ok(_), Err(e3)) => {
254255
writeln!(writer, "Decryption failed Record: {idx} Reason:{e3}",)?;
255256
eprintln!("Decryption failed Record: {idx} Reason:{e3}");
256-
if first_error.is_none() {
257-
first_error = Some(e3);
257+
if first_error.is_ok() {
258+
first_error = Err(e3);
258259
}
259260
}
260261
}
261262
}
262-
match first_error {
263-
None => Ok(()),
264-
Some(err) => Err(Box::new(err)),
265-
}
263+
264+
first_error.unwrap();
265+
Ok(())
266266
}
267267

268268
#[cfg(test)]

0 commit comments

Comments
 (0)