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
impl ApiError
Sourcepub fn engine(e: impl Display) -> Self
pub fn engine(e: impl Display) -> Self
Wraps an engine-side error as 500 Internal Server Error.
Sourcepub fn bad_request(m: String) -> Self
pub fn bad_request(m: String) -> Self
Builds a 400 Bad Request with the given message.
Sourcepub fn conflict(m: String) -> Self
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).
Sourcepub fn from_task_resolve(err: &TaskApplicationError, prefix: &str) -> Self
pub fn from_task_resolve(err: &TaskApplicationError, prefix: &str) -> Self
GH #81 Layer 1: map a TaskApplication::resolve failure into the
same recovery wording the register path already emits when the
underlying condition is that the Blueprint is archived. On the
archived branch the caller gets a 409 CONFLICT with the exact
hint blueprint {id} is archived; POST /v1/blueprints/{id}/unarchive first — byte-identical to blueprints::seed_blueprint’s message
so downstream tooling can grep either surface. Every other
TaskApplicationError falls through to the pre-#81 400 bad request shape, preserving the launch / rekick error surface for
callers that don’t distinguish store errors from other resolve
failures.
Builds a 503 Service Unavailable with the given message (GH #33
Guard 1 — operator readiness precheck).
Sourcepub fn timeout(m: String) -> Self
pub fn timeout(m: String) -> Self
Builds a 504 Gateway Timeout with the given message (GH #33
Guard 2 — sync launch timeout ceiling).
Sourcepub fn gone(m: String) -> Self
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).
Sourcepub fn payload_too_large(m: String) -> Self
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).
Sourcepub fn unprocessable(m: impl Into<String>) -> Self
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).
Sourcepub fn with_details(self, details: Value) -> Self
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 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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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