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

Better error handling #2

Closed
suhr opened this issue Jul 31, 2020 · 2 comments
Closed

Better error handling #2

suhr opened this issue Jul 31, 2020 · 2 comments
Labels
help wanted Extra attention is needed

Comments

@suhr
Copy link

suhr commented Jul 31, 2020

% tune scale 440 equal 31                                                                                                                                                                                                                      
thread 'main' panicked at 'Ratio must be finite and positive but was 0', /home/suhr/.cargo/registry/src/github.com-1ecc6299db9ec823/tune-0.10.0/src/ratio.rs:49:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

There's a handy crate for error handling: https://docs.rs/anyhow

@Woyten
Copy link
Owner

Woyten commented Jul 31, 2020

Hello @suhr! Thanks for your issue submission!

I am constantly working on improving the error handling concept. Unfortunately, I have no idea how to handle the error you reported as it is a numerical error which can occur at too many locations.

My strategy was to report all regular errors via Result and all numerical errors via .expect("..."). Do you have a good idea how numerical errors should be handled?

@Woyten Woyten added the help wanted Extra attention is needed label Aug 2, 2020
@Woyten
Copy link
Owner

Woyten commented Aug 5, 2021

I am closing this issue with the following outcome:

  • Ratio operations no longer panic (to be released with tune-0.25.0). As a result, invalid float values (e.g. negative ones) are accepted by the API and can lead to non-finite (-inf, +inf, NaN) cents values. This is acceptable since all values passed to the API - including finite ones - need to be correct anyway.
  • API code using expect in newer modules is expected to be rewritten without panics and with type-level numerical checks soon.
  • Panics in executable code are okay.
  • Code using unwrap is expected to never crash. If it does nonetheless, this is considered a bug.
  • If a panic is observed in the API code, this is considered bug.

@Woyten Woyten closed this as completed Aug 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants