Skip to main content

ApiError

Struct ApiError 

Source
pub struct ApiError {
    pub status: StatusCode,
    pub kind: String,
    pub message: String,
}
Expand description

Error type returned by every fallible handler.

Fields§

§status: StatusCode

HTTP status code to send.

§kind: String

Stable machine-readable identifier (the kind field on the wire).

§message: String

Human-readable description.

Implementations§

Source§

impl ApiError

Source

pub fn bad_request(kind: impl Into<String>, message: impl Into<String>) -> Self

Construct a 400 Bad Request with the given kind and message.

Source

pub fn forbidden(kind: impl Into<String>, message: impl Into<String>) -> Self

Construct a 403 Forbidden with the given kind and message. Used by per-tenant authorization to return kind = "tenant_scope_denied" when the caller’s bearer token does not cover the bound tenant.

Source

pub fn not_found(message: impl Into<String>) -> Self

Construct a 404 Not Found with kind = "not_found".

Source

pub fn conflict(kind: impl Into<String>, message: impl Into<String>) -> Self

Construct a 409 Conflict with the given kind and message.

Used by the kernel registry’s POST /kernels path to surface kind = "already_registered" when a manifest with the same name@version has already been published. The (409, kind) pair is the documented contract for “the request is well-formed but would violate a uniqueness invariant”; clients should NOT retry without changing the request (no Retry-After header).

Source

pub fn service_unavailable( kind: impl Into<String>, message: impl Into<String>, ) -> Self

Construct a 503 Service Unavailable with the given kind and message.

Used by the kernel registry routes to surface kind = "kernel_registry_not_configured" when the gateway is running without TENSOR_WASM_API_KERNEL_HMAC_KEY set. Distinct from capacity_exhausted (also 503) because the failure mode is configuration, not load — a client should NOT retry, it should surface the error to an operator who can flip the env knob.

Source

pub fn internal(message: impl Into<String>) -> Self

Construct a 500 Internal Server Error with kind = "internal".

Source

pub fn not_implemented( kind: impl Into<String>, message: impl Into<String>, ) -> Self

Construct a 501 Not Implemented with the given kind and message.

Used by the snapshot routes (M5) for the parts of full live-instance snapshot / restore that still need executor support: /snapshot/save signs and returns a snapshot blob built from the function’s deployed bytes (the HMAC envelope layer is fully wired), but capturing a running instance’s linear / GPU memory needs a TensorWasmExecutor capture hook that does not exist yet — that capability surfaces 501 not_implemented rather than silently returning an empty or misleading capture. The (501, kind) pair is the documented contract; clients should NOT retry.

Source

pub fn body_too_large(message: impl Into<String>) -> Self

Construct a 413 Payload Too Large with kind = "body_too_large".

Returned when an inbound request body exceeds the global MAX_REQUEST_BODY_BYTES cap. The rejection is surfaced through axum’s DefaultBodyLimit::max at extract time — see From<JsonRejection> for the routing that translates the underlying JsonRejection::BytesRejection(LengthLimitError) into this variant instead of the generic invalid_json 400.

The body_too_large kind is pinned in [API.md] and [openapi.json]; clients can rely on the (kind, status) pair without inspecting message.

Source

pub fn to_kind_message(&self) -> (String, String)

Render this error into the canonical (kind, message) pair so the async job recorder can persist the same shape callers see from the synchronous path.

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<ExecError> for ApiError

Source§

fn from(err: ExecError) -> Self

Converts to this type from the input type.
Source§

impl From<JsonRejection> for ApiError

Source§

fn from(rej: JsonRejection) -> 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<T> FutureExt for T

Source§

fn with_context(self, otel_cx: Context) -> WithContext<Self>

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
Source§

fn with_current_context(self) -> WithContext<Self>

Attaches the current Context to this type, returning a WithContext wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. 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 = 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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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