nicholascioli / rbroadlink

A broadlink library written in Rust. Based on https://github.com/mjg59/python-broadlink
https://crates.io/crates/rbroadlink
MIT License
3 stars 5 forks source link

Remove panics via expect #2

Closed Wazner closed 9 months ago

Wazner commented 1 year ago

My application kept crashing due to panics when the broadlink device was temporary unavailable. I refactored all .expect calls to .map_err to return string errors for all errors. The original error is appended to still be able to determine the root cause.

Would probably be better to use an Error type instead to be able to reason about the origin of the error programmatically and prevent allocation of strings when the error is not displayed. Don't really have a use-case for that now though, so strings are fine.

nicholascioli commented 9 months ago

Sorry for the super long delay; I'll look at this soon!

nicholascioli commented 9 months ago

This looks great! I'll probably go through and add real error types later, but thanks for your PR!