Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.

Add Overflow to DispatchError #8544

Closed
shawntabrizi opened this issue Apr 6, 2021 · 2 comments · Fixed by #8726
Closed

Add Overflow to DispatchError #8544

shawntabrizi opened this issue Apr 6, 2021 · 2 comments · Fixed by #8726
Labels
Z1-easy Can be fixed primarily by duplicating and adapting code by an intermediate coder Z6-mentor An easy task where a mentor is available. Please indicate in the issue who the mentor could be.

Comments

@shawntabrizi
Copy link
Member

Almost any pallet dealing with numbers will be checking at some point for overflows / underflows in their math.

Each pallet that wants to do that will need to write a custom Error into their pallet for that.

I think Overflow is generic enough that it could fit into the DispatchError enum, and thus be accessible to all pallets without any extra code.

To complete this issue, all existing uses of custom Overflow or Underflow errors should be replaced with DispatchError::Overflow

@shawntabrizi shawntabrizi added Z1-easy Can be fixed primarily by duplicating and adapting code by an intermediate coder Z6-mentor An easy task where a mentor is available. Please indicate in the issue who the mentor could be. labels Apr 6, 2021
@shawntabrizi
Copy link
Member Author

This would be a great first issue to anyone new to Rust in general. Try to keep your hands off if you too think this would be easy for you :)

@shaunxw
Copy link
Contributor

shaunxw commented Apr 7, 2021

If overflow/underflow has an static str, it would be easier to tell which part could overflow. It's helpful when a dispatchable call has multiple overflow/underflow checks for different data.

I think a DispatchError::Arithmetic(ArithmeticError) might be more generic, to handle all common calculation errors, including overflow/underflow, division by zero etc.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Z1-easy Can be fixed primarily by duplicating and adapting code by an intermediate coder Z6-mentor An easy task where a mentor is available. Please indicate in the issue who the mentor could be.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants