#[non_exhaustive]pub enum Error {
Network {
message: String,
},
Auth {
message: String,
},
Rejected {
message: String,
},
Parse {
message: String,
},
Unsupported {
message: String,
},
}Expand description
Typed error for every shelly-core transport path.
The five variants map 1:1 onto switchkit::Error: a caller that already
speaks that vocabulary can translate this enum without guesswork.
#[non_exhaustive] because the error taxonomy is expected to grow; this
is free to add now and a breaking change to add later, for a crate about
to publish its first crates.io release.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Network
The device could not be reached at all (connect/timeout/read failure), or it responded with a non-success HTTP status that is not an auth failure.
Auth
The device rejected the request because of missing or invalid credentials (HTTP 401/403).
Rejected
The device was reached, answered with a well-formed response, but
explicitly rejected the request (a Gen2 RPC error object in an
HTTP 200 body).
Parse
The device was reached but its response could not be interpreted:
invalid JSON, or a /shelly body that does not describe a Shelly
device. Reachable-but-not-Shelly is deliberately Parse, not
Network, so callers can distinguish “nothing there” from “something
else is there”.
Unsupported
The operation is genuinely not supported, either by this device
generation or by this client (replaces the old anyhow::bail!("not supported") paths).
Trait Implementations§
Source§impl Error for Error
impl Error for Error
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
Source§impl From<Error> for Error
Classify a raw reqwest::Error into a typed Error.
impl From<Error> for Error
Classify a raw reqwest::Error into a typed Error.
reqwest::Error already distinguishes response-decode failures
(is_decode) from connect/timeout/request-level failures, so a plain ?
on send()/json() calls routes through this impl and lands on the
right variant without every call site repeating the classification.
Auto Trait Implementations§
impl Freeze for Error
impl RefUnwindSafe for Error
impl Send for Error
impl Sync for Error
impl Unpin for Error
impl UnsafeUnpin for Error
impl UnwindSafe for Error
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.