pub struct ApiError {
pub status: StatusCode,
pub kind: String,
pub message: String,
}Expand description
Error type returned by every fallible handler.
Fields§
§status: StatusCodeHTTP status code to send.
kind: StringStable machine-readable identifier (the kind field on the wire).
message: StringHuman-readable description.
Implementations§
Source§impl ApiError
impl ApiError
Sourcepub fn bad_request(kind: impl Into<String>, message: impl Into<String>) -> Self
pub fn bad_request(kind: impl Into<String>, message: impl Into<String>) -> Self
Construct a 400 Bad Request with the given kind and message.
Sourcepub fn forbidden(kind: impl Into<String>, message: impl Into<String>) -> Self
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.
Sourcepub fn not_found(message: impl Into<String>) -> Self
pub fn not_found(message: impl Into<String>) -> Self
Construct a 404 Not Found with kind = "not_found".
Sourcepub fn conflict(kind: impl Into<String>, message: impl Into<String>) -> Self
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).
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.
Sourcepub fn internal(message: impl Into<String>) -> Self
pub fn internal(message: impl Into<String>) -> Self
Construct a 500 Internal Server Error with kind = "internal".
Sourcepub fn not_implemented(
kind: impl Into<String>,
message: impl Into<String>,
) -> Self
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.
Sourcepub fn body_too_large(message: impl Into<String>) -> Self
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.
Sourcepub fn to_kind_message(&self) -> (String, String)
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 From<JsonRejection> for ApiError
impl From<JsonRejection> for ApiError
Source§fn from(rej: JsonRejection) -> Self
fn from(rej: JsonRejection) -> Self
Source§impl IntoResponse for ApiError
impl IntoResponse for ApiError
Source§fn into_response(self) -> Response
fn into_response(self) -> Response
Auto Trait Implementations§
impl Freeze for ApiError
impl RefUnwindSafe for ApiError
impl Send for ApiError
impl Sync for ApiError
impl Unpin for ApiError
impl UnsafeUnpin for ApiError
impl UnwindSafe for ApiError
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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