substrate-docs
substrate-docs copied to clipboard
Avoid panic in examples
Content request
In some examples, we include panicking code. If examples like these are meant to be in the runtime, would they not risk panicking the runtime?
One example reported is here:
let updated_from_balance = sender_balance.checked_sub(value).ok_or(<Error<T>>::InsufficientFunds)?;
let updated_to_balance = receiver_balance.checked_add(value).expect("Entire supply fits in u64, qed");
An example fix might be to instead of using the expect, return an Error similar to the previous line.
Are you willing to help with this request?
Yes!
@justinFrevert absolutely would be open to have you pick out these and fix :pray: :heart: