When a function already returns a Result, propagate errors instead of panicking with expect
For NovaError::SynthesisError, retain information about the original bellpepper error. Since NovaError implements Clone but bellpepper's SynthesisError does not, we keep the error information as a String.
This commit only fixes low-hanging fruit in lib.rs, for functions that already return a Result and can easily propagate errors just by replacing expect(...) with ?. There are still many unwrap() calls in functions returning Result in other modules, particularly gadgets. But I don't understand the code well in those parts, and I suspect some of those unwrap()s actually can't fail based on invariants of the code, so it makes perfect sense to leave them as is.
Result
, propagate errors instead of panicking withexpect
NovaError::SynthesisError
, retain information about the original bellpepper error. SinceNovaError
implementsClone
but bellpepper'sSynthesisError
does not, we keep the error information as aString
.This commit only fixes low-hanging fruit in lib.rs, for functions that already return a
Result
and can easily propagate errors just by replacingexpect(...)
with?
. There are still manyunwrap()
calls in functions returningResult
in other modules, particularly gadgets. But I don't understand the code well in those parts, and I suspect some of thoseunwrap()
s actually can't fail based on invariants of the code, so it makes perfect sense to leave them as is.