Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

consider using defensive traits where appropriate #573

Open
enthusiastmartin opened this issue Nov 2, 2022 · 0 comments
Open

consider using defensive traits where appropriate #573

enthusiastmartin opened this issue Nov 2, 2022 · 0 comments

Comments

@enthusiastmartin
Copy link
Contributor

Consider using defensive traits

https://github.com/paritytech/substrate/blob/master/frame/support/src/traits/misc.rs

where it would be appropriate and helpful.

Mostly places where you expect infallible code ( basically places where comments such as "cannot happen" , "should not happen", "it is safe because of previous condition" are found,)

Eg.

  • defensive_ok_or
  • defensive_saturating_add
  • etc.

This would be helpful in following way:

  1. it panics on debug_assertion, which means if you reach this error in tests, it panics.
  2. it logs error in production using runtime logging system. Which might help detecting potential problems.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant