Skip to main content

MisarDevError

Enum MisarDevError 

Source
pub enum MisarDevError {
    Validation(ApiError),
    Authentication(ApiError),
    PermissionDenied(ApiError),
    NotFound(ApiError),
    Conflict(ApiError),
    RateLimit(Box<RateLimitError>),
    Server(ApiError),
    PlanLimit(Box<PlanLimitError>),
    Api(ApiError),
    Network {
        message: String,
        source: Option<Error>,
    },
    MissingApiKey,
    Config(String),
}
Expand description

Every error the SDK returns.

Variants§

§

Validation(ApiError)

400 / 422 — the request was malformed or failed validation.

§

Authentication(ApiError)

401 — the key is missing, revoked, expired, or not a MisarDev key.

§

PermissionDenied(ApiError)

403 — authenticated, but not allowed to touch this resource.

§

NotFound(ApiError)

404 — no such resource, or not one this key can see.

§

Conflict(ApiError)

409 — conflicts with current state (e.g. a build already running).

§

RateLimit(Box<RateLimitError>)

429 that is an ordinary throttle, after the client already retried it.

§

Server(ApiError)

5xx — the API failed. Retried automatically for idempotent requests.

§

PlanLimit(Box<PlanLimitError>)

The plan behind the key does not cover this call. Never retried.

§

Api(ApiError)

Any other non-2xx status.

§

Network

The request never got an HTTP answer (DNS, TLS, reset, timeout). Status 0.

Fields

§message: String
§source: Option<Error>
§

MissingApiKey

No API key was passed and MISARDEV_API_KEY is unset.

§

Config(String)

The client could not be configured (e.g. the HTTP client failed to build).

Implementations§

Source§

impl MisarDevError

Source

pub fn api_error(&self) -> Option<&ApiError>

The shared fields, when this is an HTTP error.

Source

pub fn status(&self) -> u16

HTTP status, or 0 when there was no HTTP answer.

Source

pub fn message(&self) -> String

Human-readable message.

Source

pub fn code(&self) -> Option<&str>

Machine-readable code from the body, when sent.

Source

pub fn body(&self) -> Option<&Value>

The decoded error body.

Source

pub fn request_id(&self) -> Option<&str>

The x-request-id header.

Source

pub fn rate_limit(&self) -> Option<&RateLimitError>

The throttle details, when this is an ordinary rate limit.

Source

pub fn plan_limit(&self) -> Option<&PlanLimitError>

The plan-limit details, when this is a plan refusal.

Source

pub fn is_retryable(&self) -> bool

Worth retrying as-is: a throttle or a transient server condition.

Trait Implementations§

Source§

impl Debug for MisarDevError

Source§

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

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

impl Display for MisarDevError

Source§

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

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

impl Error for MisarDevError

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 MisarDevError

Source§

fn from(e: Error) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

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 = !

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

fn try_from(value: U) -> Result<T, !>

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