timescaledb-toolkit icon indicating copy to clipboard operation
timescaledb-toolkit copied to clipboard

replace unwrap() with expect("unique message")

Open kvc0 opened this issue 2 years ago • 1 comments

unwrap() gives no clues where to look when a bug arises. This change replaces common tdigest unwrap() calls with expect("message").

This does the same thing as unwrap(), it just provides more context for users to report with bugs.

Fwiw, I find that explaining an expectation in rust can sometimes show me that the expectation is unreasonable. I can't come up with good explanations for some of these, but I gave an effort to at least provide a first-approximation of what the expectation at work is. Any refinements to what these expectations are actually trying to assert would be welcome!

It would be nice to be able to provide more information for https://github.com/timescale/timescaledb-toolkit/issues/680

I've only got a couple years of experience with Rust, but I'd strongly recommend taking a "no unwrap() outside of tests" policy!

kvc0 avatar Jan 13 '23 05:01 kvc0

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Jan 13 '23 05:01 CLAassistant