Skip to main content

ApiError

Struct ApiError 

Source
pub struct ApiError { /* private fields */ }
Expand description

Uniform error response type for the handlers in this module. Converts to a JSON {"error": message} body with the given status via IntoResponse.

GH #76 error surface: an optional details field carries the structured mlua_swarm::service::TaskLaunchError::FlowEval envelope (failed_step / verdict_value / partial_ctx) when the abort originated from a Blueprint step. When present, the JSON body becomes {"error": message, "details": {...}} — a pure ADDITIVE schema change for consumers that already ignore unknown keys. Absent (the default) preserves the pre-#76 {"error": message} shape byte-for-byte for every other error site.

Implementations§

Source§

impl ApiError

Source

pub fn engine(e: impl Display) -> Self

Wraps an engine-side error as 500 Internal Server Error.

Source

pub fn not_found(m: String) -> Self

Builds a 404 Not Found with the given message.

Source

pub fn bad_request(m: String) -> Self

Builds a 400 Bad Request with the given message.

Source

pub fn conflict(m: String) -> Self

Builds a 409 Conflict with the given message (POST /v1/runs/:id/resume — the Run is not Interrupted, or a concurrent resume already won the Interrupted -> Running compare-and-set).

Source

pub fn unavailable(m: String) -> Self

Builds a 503 Service Unavailable with the given message (GH #33 Guard 1 — operator readiness precheck).

Source

pub fn timeout(m: String) -> Self

Builds a 504 Gateway Timeout with the given message (GH #33 Guard 2 — sync launch timeout ceiling).

Source

pub fn gone(m: String) -> Self

Builds a 410 Gone with the given message (GH #37 — worker submit/artifact addressed at a Run that already reached a terminal status; the silent-204-then-orphan alternative is the failure shape this replaces).

Source

pub fn payload_too_large(m: String) -> Self

Builds a 413 Payload Too Large with the given message (GH #42 — @file: sentinel resolves to a file larger than the shared DefaultBodyLimit; same size ceiling as the inline body path).

Source

pub fn unprocessable(m: impl Into<String>) -> Self

Builds a 422 Unprocessable Entity with the given message (GH #50 — a worker_submit / worker_artifact value violates the dispatching agent’s declared VerdictContract: rejected before it reaches submit_worker_result_trusted / stage_worker_artifact_trusted, i.e. before it can land in the flow ctx).

Source

pub fn with_details(self, details: Value) -> Self

GH #76 error surface: attach a structured details payload alongside the string message. Consumed by IntoResponse to emit {"error": message, "details": {...}}. The current sole caller is run_flow_form’s TaskApplicationError::Launch(FlowEval) arm, which lifts failed_step / verdict_value / partial_ctx out of the structured mlua_swarm::service::TaskLaunchError::FlowEval variant into this field.

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 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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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