-
Notifications
You must be signed in to change notification settings - Fork 14
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
Use thiserror
rather than eyre
in mijia
crate
#83
Conversation
8bc19e2
to
5f3d016
Compare
d7fed4f
to
b7a4d7e
Compare
Error is just a re-export of Report.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See what this does to the backtraces and then ship it? Would be nice to know whether converting from box dyn Error to thiserror to eyre throws stack frames away. It may be that the backtrace
crate registers itself in a magical way that makes everything get preserved, but I'm also okay with losing a few frames of dbus-rs as long as we can still report the place where our thiserror is being constructed.
if value.len() != 6 { | ||
bail!("Wrong length {} for comfort level", value.len()); | ||
} | ||
pub(crate) fn decode(value: &[u8]) -> Result<ComfortLevel, DecodeError> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(probably not something to touch in this PR): Now that I this is feeling quite a lot like the signature of impl TryFrom<&[u8]> for ComfortLevel
and decode() feels like impl TryFrom<ComfortLevel> for [u8, 6]
It may be that converting these all to TryInto will destroy the ergonomics at the call site though. We would certainly need provide a newtype for SystemTime if we went in this direction.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would mean that the decoding logic is part of the public API of the crate, which I'm not sure we want. I was considering adding some private traits, but it doesn't really give any advantage, and prevents some of the slight differences in signatures we currently have (e.g. encoding TemperatureUnit
can't fail, so doesn't return a Result
).
Backtraces go up to the point that |
It seems more appropriate for a library.