#[derive(Debug, thiserror::Error)] pub enum Error { #[error("HTTP request failed: {0}")] Http(String), #[error("device returned {status}: {body}")] Status { status: u16, body: String }, #[error("mDNS: {0}")] Mdns(String), #[error("I/O: {0}")] Io(#[from] std::io::Error), #[error("device unreachable — check Wi-Fi Transfer toggle")] Unreachable, } impl Error { /// `Status` is not produced here. ureq 3's `Error::StatusCode` carries only /// the code, never the response, so the agent turns off /// `http_status_as_error` and `browse` checks the status while it still /// holds the body. See `browse::status_error`. pub(crate) fn from_http(e: ureq::Error) -> Self { match e { ureq::Error::Io(io) => Self::Io(io), other => Self::Http(other.to_string()), } } // e is consumed into the stringified error variant. #[allow(clippy::needless_pass_by_value)] pub(crate) fn from_mdns(e: mdns_sd::Error) -> Self { Self::Mdns(e.to_string()) } }