pub enum Error {
Status {
method: &'static str,
path: String,
status: u16,
detail: String,
problem: Option<Box<Problem>>,
body: String,
},
Transport(Error),
Decode {
path: String,
source: Error,
},
BaseUrl(String),
Io {
path: String,
source: Error,
},
Timeout {
verb: &'static str,
path: String,
after: Duration,
},
Unauthenticated,
}Variants§
Status
The server answered with a non-200 status.
The control plane returns 200 for every success, including the ones that carry no body, so anything else is a refusal worth surfacing.
Fields
Transport(Error)
Decode
BaseUrl(String)
Io
A local file could not be read or written. Only the two archive calls touch the filesystem, and a failure there is the user’s disk rather than the box, so it must not read as an API error.
Timeout
The box did not answer within the deadline.
Distinct from Transport on purpose. A transport error means something
said no — the connection was refused, the name did not resolve, TLS was
rejected — and the user can usually act on it. This means the box said
nothing at all, which points at a different set of causes: a tunnel that
is down, a machine that is asleep, a box under load. Telling a user
“it did not answer” when the truth is “it refused” sends them looking in
the wrong place.
Unauthenticated
No session token is set but the endpoint requires one.
Implementations§
Source§impl Error
impl Error
Sourcepub fn http_status(&self) -> Option<u16>
pub fn http_status(&self) -> Option<u16>
The HTTP status, when this was a refusal from the server.
Sourcepub fn is_unauthenticated(&self) -> bool
pub fn is_unauthenticated(&self) -> bool
Whether the session token was rejected, so the UI should send the user back to the sign-in screen rather than showing an error.
A 401 is a token the server will not accept at all; a 403 is a token it accepts from an account that lacks the grant, which is a real answer and not a reason to sign out.
Sourcepub fn is_forbidden(&self) -> bool
pub fn is_forbidden(&self) -> bool
Whether the account is authenticated but lacks the grant this endpoint needs. Most write paths are admin-only, so a read-only account hits this routinely and it should read as “not yours to change”, not as a fault.
Sourcepub fn is_unreachable(&self) -> bool
pub fn is_unreachable(&self) -> bool
Whether the box could not be reached at all, as opposed to answering with something the user needs to know about.
Both of these mean “there is nothing to talk to here”: a transport failure is a refusal, a timeout is a silence. The UI groups them because the user’s next move is the same for both — check the address, check the tunnel — and neither is worth the alarm of a red error on a first run against a box that is simply not up yet.
Trait Implementations§
Source§impl Error for Error
impl Error for Error
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()