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

Review error handling within Decimal #49

Open
paupino opened this issue Oct 5, 2017 · 2 comments
Open

Review error handling within Decimal #49

paupino opened this issue Oct 5, 2017 · 2 comments

Comments

@paupino
Copy link
Owner

paupino commented Oct 5, 2017

There are some areas where panic is warranted however there are others (e.g. rescale, from_bytes_le) that we could utilize Rust's error handling further. In addition, with libraries such as error-chain we can perhaps make the error handling experience richer with little overhead.

@jekirl
Copy link
Contributor

jekirl commented Oct 7, 2017

I would propose that panics be only for truly unrecoverable errors, which in this case should be limited to debug mode perhaps? In general I think there should be no panics for the Mul/Add/Div/Sub/etc traits, and instead there be a checked_mul/div/add/sub/etc function for each implemented under the Decimal trait that returns an error type (through error-chain). Perhaps having panic on release and/or debug can be a feature flag?

@paupino
Copy link
Owner Author

paupino commented Nov 28, 2017

Have expanded checked operators into #80. I do like the idea of debug mode only panic's however would like to perhaps come up with a clear set of rules. For div, for example, I'm thinking:

  • Div by zero = panic. If not panic, what would make sense to return? We could introduce the concept of Infinity within flags?
  • Overflow = Saturate
  • Underflow = Round

Thoughts?

@paupino paupino added this to the V1.X milestone Aug 23, 2019
@paupino paupino removed this from the V1.X milestone Nov 10, 2020
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

2 participants