You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The best example is in calculate_targeted_long_with_budget, where we do:
.map_err(|err| {
PyErr::new::<PyValueError, _>(format!(
"Calculate_targeted_long_with_budget returned the error: {:?}",
err
))
})?;
But that's the only place we do it.
In calculate_spot_price_after_short we do something like that but throw away the actual err. In most other fns we use unwrap(), which throws a cryptic panic message. We should follow the targeted long example everywhere.
The text was updated successfully, but these errors were encountered:
# Resolved Issues
#99#64#65#66
# Description
Our use of both panic and result results in a worse developer
experience, and should be changed to using Result everywhere possible.
This PR removes almost all `panic` uses in the core libs; where
functions once would panic but return a type `T` they now return an
error with the type`Result<T>`. I also removed `unwrap()` statements,
which convert `Result` to `panic`, in most places around the repo.
Exceptions were made for core (anything with sugar like `+`, `-`, `*`)
FixedPoint arithmetic (thus keeping any U256 panics), certain
test-related cases, and macros.
I also improved some error messaging (in bindings mostly, but also
elsewhere), added comments, & added a lint ignore.
I ran the fuzz testing with 10k `FUZZ_RUNS` and 50k `FAST_FUZZ_RUNS`
twice without error locally.
The best example is in
calculate_targeted_long_with_budget
, where we do:But that's the only place we do it.
In
calculate_spot_price_after_short
we do something like that but throw away the actualerr
. In most other fns we useunwrap()
, which throws a cryptic panic message. We should follow the targeted long example everywhere.The text was updated successfully, but these errors were encountered: