You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
% 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
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?
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.
There's a handy crate for error handling: https://docs.rs/anyhow
The text was updated successfully, but these errors were encountered: