Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ea26d4c

Browse files
authored
fix: avoid panics by propagating errors in outputs parsing and proof writing (0xMiden#2191)
1 parent f738fc2 commit ea26d4c

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

miden-vm/src/cli/data.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,12 @@ impl OutputFile {
9797

9898
/// Converts stack output vector to [StackOutputs].
9999
pub fn stack_outputs(&self) -> Result<StackOutputs, String> {
100-
let stack = self.stack.iter().map(|v| v.parse::<u64>().unwrap()).collect::<Vec<u64>>();
100+
let stack = self
101+
.stack
102+
.iter()
103+
.map(|v| v.parse::<u64>())
104+
.collect::<Result<Vec<u64>, _>>()
105+
.map_err(|err| format!("Failed to parse stack output as u64 - {err}"))?;
101106

102107
StackOutputs::try_from_ints(stack)
103108
.map_err(|e| format!("Construct stack outputs failed {e}"))
@@ -223,7 +228,8 @@ impl ProofFile {
223228
let proof_bytes = proof.to_bytes();
224229

225230
// write proof bytes to file
226-
file.write_all(&proof_bytes).unwrap();
231+
file.write_all(&proof_bytes)
232+
.map_err(|err| format!("Failed to write proof file `{}` - {}", path.display(), err))?;
227233

228234
Ok(())
229235
}

0 commit comments

Comments
 (0)