Skip to main content

Error

Struct Error 

Source
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

Source

pub fn new( status: StatusCode, code: &'static str, message: impl Into<String>, ) -> Self

Build an error with an explicit status and stable code.

Source

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

Source

pub fn not_found() -> Self

Source

pub fn method_not_allowed() -> Self

Source

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

The write conflicts with existing state (e.g. a unique key already taken).

Source

pub fn payload_too_large() -> Self

Source

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).

Source

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

Source

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.

Source

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.

Source

pub fn unauthorized() -> Self

Authentication is required or failed (spec §4.4 auth).

Source

pub fn forbidden() -> Self

Authenticated but not permitted.

Source

pub fn handler_timeout() -> Self

The handler exceeded the configured time budget (spec §4.4 timeouts).

Source

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

Source

pub fn missing_dependency(type_name: &str) -> Self

A handler or dependency asked for a type no provider supplies (spec §4.3).

Source

pub fn dependency_cycle() -> Self

Dependency factories recursed past the depth limit (cycle, or absurd chain).

Source

pub fn task_context() -> Self

An HTTP extractor ran inside a task context (no request to read from).

Source

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.

Source

pub fn details(&self) -> Option<&Value>

Source

pub fn status(&self) -> StatusCode

Source

pub fn code(&self) -> &'static str

Source

pub fn message(&self) -> &str

Trait Implementations§

Source§

impl Debug for Error

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for Error

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Error for Error

1.30.0 · Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0:

use the Display impl or to_string()

1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl IntoResponse for Error

Auto Trait Implementations§

§

impl Freeze for Error

§

impl RefUnwindSafe for Error

§

impl Send for Error

§

impl Sync for Error

§

impl Unpin for Error

§

impl UnsafeUnpin for Error

§

impl UnwindSafe for Error

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<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
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.