Skip to main content

Error

Enum Error 

Source
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

§method: &'static str
§path: String
§status: u16
§detail: String
§problem: Option<Box<Problem>>

Boxed because this variant otherwise sets the size of every Result the crate returns, and Problem is 80 bytes of it. Every method here is fallible, so the cost is paid on every call and the refusal that needs the allocation is the rare path.

§body: String
§

Transport(Error)

§

Decode

Fields

§path: String
§source: Error
§

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.

Fields

§path: String
§source: 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.

Fields

§verb: &'static str
§path: String
§after: Duration
§

Unauthenticated

No session token is set but the endpoint requires one.

Implementations§

Source§

impl Error

Source

pub fn http_status(&self) -> Option<u16>

The HTTP status, when this was a refusal from the server.

Source

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.

Source

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.

Source

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.

Source

pub fn detail(&self) -> String

A message fit to put in front of a user.

Trait Implementations§

Source§

impl Debug for Error

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for Error

Source§

fn fmt(&self, __formatter: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Error for Error

Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0:

use the Display impl or to_string()

1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl From<Error> for Error

Source§

fn from(source: Error) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl !RefUnwindSafe for Error

§

impl !UnwindSafe for Error

§

impl Freeze for Error

§

impl Send for Error

§

impl Sync for Error

§

impl Unpin for Error

§

impl UnsafeUnpin for Error

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more