Skip to main content

ApiError

Struct ApiError 

Source
pub struct ApiError {
    pub status: StatusCode,
    pub code: &'static str,
    pub title: String,
    pub generation: Option<Generation>,
    pub balance_exhaustion: Option<BalanceExhaustion>,
    pub balance_shortfall: Option<BalanceShortfall>,
}
Expand description

A refused control-plane request, rendered as an RFC-7807 application/problem+json body in the Problem shape.

A 401 also carries a Bearer challenge. A 5xx or usage-refused response adds an optional error_id that matches a warning on the tollgate::diagnostics target. Converting a StoreError never exposes its text, in the body or in Debug output (INVARIANTS.md 37).

Fields§

§status: StatusCode

The HTTP status, also sent as the body’s status.

§code: &'static str

The stable machine code clients classify the refusal by. Part of the wire contract.

§title: String

A short public description. Not a contract; classify by status and code.

§generation: Option<Generation>

The tombstone’s generation on a revoked-principal refusal.

§balance_exhaustion: Option<BalanceExhaustion>

The allocator’s evidence on a balance-exhausted refusal.

§balance_shortfall: Option<BalanceShortfall>

The remaining funding on an insufficient-balance refusal, when the allocator attested it.

Implementations§

Source§

impl ApiError

Source

pub fn unauthorized() -> Self

401 authentication-required: credentials are missing, invalid, expired or conflicting. The response carries a Bearer challenge.

Source

pub fn forbidden() -> Self

403 scope-forbidden: the credential is valid, but its identity lacks the role this route requires.

Source

pub fn not_found(code: &'static str, title: impl Into<String>) -> Self

404 with the given machine code and title.

Source

pub fn revoked(generation: Generation) -> Self

410 revoked-principal: the principal’s snapshot is a tombstone. Carries the tombstone’s generation so a client can order it against the positive snapshots it holds (INVARIANTS.md 15).

Source

pub fn bad_request(code: &'static str, title: impl Into<String>) -> Self

400 with the given machine code and title.

Source

pub fn not_implemented(code: &'static str, title: impl Into<String>) -> Self

The backend cannot answer this at all, as opposed to answering “nothing” — a distinction a caller must be able to act on differently (GL-48).

Trait Implementations§

Source§

impl Debug for ApiError

Source§

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

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

impl From<AllocateError> for ApiError

Source§

fn from(e: AllocateError) -> Self

Converts to this type from the input type.
Source§

impl From<BudgetError> for ApiError

Source§

fn from(e: BudgetError) -> Self

Converts to this type from the input type.
Source§

impl From<CreateAccountError> for ApiError

Source§

fn from(e: CreateAccountError) -> Self

Converts to this type from the input type.
Source§

impl From<IngestError> for ApiError

Source§

fn from(error: IngestError) -> Self

Converts to this type from the input type.
Source§

impl From<JsonRejection> for ApiError

Source§

fn from(error: JsonRejection) -> Self

Converts to this type from the input type.
Source§

impl From<KeyError> for ApiError

Source§

fn from(e: KeyError) -> Self

Converts to this type from the input type.
Source§

impl From<KeySnapshotError> for ApiError

Source§

fn from(e: KeySnapshotError) -> Self

Converts to this type from the input type.
Source§

impl From<PathRejection> for ApiError

Source§

fn from(error: PathRejection) -> Self

Converts to this type from the input type.
Source§

impl From<PublishSnapshotError> for ApiError

Source§

fn from(e: PublishSnapshotError) -> Self

Converts to this type from the input type.
Source§

impl From<SetStatusError> for ApiError

Source§

fn from(e: SetStatusError) -> Self

Converts to this type from the input type.
Source§

impl From<SnapshotValidationError> for ApiError

Source§

fn from(error: SnapshotValidationError) -> Self

Converts to this type from the input type.
Source§

impl From<StoreError> for ApiError

Source§

fn from(_: StoreError) -> Self

Converts to this type from the input type.
Source§

impl IntoResponse for ApiError

Source§

fn into_response(self) -> Response

Create a response.

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<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,

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> Same for T

Source§

type Output = T

Should always be Self
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