pub struct Error { /* private fields */ }Expand description
The one error type of the framework (spec §4.1 “Errors”).
Production responses render only code + message as JSON; internals
(sources, backtraces) are for logs — enforced in Phase 1’s observe layer.
Implementations§
Source§impl Error
impl Error
Sourcepub fn new(
status: StatusCode,
code: &'static str,
message: impl Into<String>,
) -> Self
pub fn new( status: StatusCode, code: &'static str, message: impl Into<String>, ) -> Self
Build an error with an explicit status and stable code.
pub fn bad_request(message: impl Into<String>) -> Self
pub fn not_found() -> Self
pub fn method_not_allowed() -> Self
Sourcepub fn conflict(message: impl Into<String>) -> Self
pub fn conflict(message: impl Into<String>) -> Self
The write conflicts with existing state (e.g. a unique key already taken).
pub fn payload_too_large() -> Self
Sourcepub fn unsupported_media_type() -> Self
pub fn unsupported_media_type() -> Self
The request’s content type is not what this endpoint consumes (e.g. a
Multipart extractor on a non-multipart/form-data request).
pub fn unprocessable(message: impl Into<String>) -> Self
Sourcepub fn too_many_requests() -> Self
pub fn too_many_requests() -> Self
The client exceeded its configured rate limit for the current window
(the rate-limit extension; spec §v2.2). The response also carries a
Retry-After header, which the middleware sets — Error has no header
channel.
Sourcepub fn job_failed(message: impl Into<String>) -> Self
pub fn job_failed(message: impl Into<String>) -> Self
A background job exhausted its retries and was dead-lettered, or failed irrecoverably (the jobs engine; spec §v2.3). Surfaced in operator logs and the dead-letter table, not to an HTTP client.
Authentication is required or failed (spec §4.4 auth).
Sourcepub fn handler_timeout() -> Self
pub fn handler_timeout() -> Self
The handler exceeded the configured time budget (spec §4.4 timeouts).
pub fn internal(message: impl Into<String>) -> Self
Sourcepub fn missing_dependency(type_name: &str) -> Self
pub fn missing_dependency(type_name: &str) -> Self
A handler or dependency asked for a type no provider supplies (spec §4.3).
Sourcepub fn dependency_cycle() -> Self
pub fn dependency_cycle() -> Self
Dependency factories recursed past the depth limit (cycle, or absurd chain).
Sourcepub fn task_context() -> Self
pub fn task_context() -> Self
An HTTP extractor ran inside a task context (no request to read from).
Sourcepub fn with_details(self, details: Value) -> Self
pub fn with_details(self, details: Value) -> Self
Attach machine-readable detail (e.g. validation violations). Rendered
as a details key in the response body; absent otherwise.
pub fn details(&self) -> Option<&Value>
pub fn status(&self) -> StatusCode
pub fn code(&self) -> &'static str
pub fn message(&self) -> &str
Trait Implementations§
Source§impl Error for Error
impl Error for Error
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()