svartalf / rust-battery

Rust crate providing cross-platform information about the notebook batteries.
https://crates.io/crates/battery
Apache License 2.0
354 stars 40 forks source link

Separate the error types #31

Open svartalf opened 5 years ago

svartalf commented 5 years ago

This battop issue had introduced the case, when the Battery struct instance can represent the missing device. While it is possible now to handle that case (see #29), this kind of error seems to be a recoverable type of error for library users (mostly to the battop at the moment), because it can be handled (for example, by removing the device from the batteries list).

battery::Error can be reworked as an enum with the "recoverable" and "non-recoverable" members, smth like this:

enum Error {
    /// Battery device is missing now
    Gone(io::Error),
    /// Some error happened during the information fetch
    Other(io::Error),
}