Skip to main content

WebError

Enum WebError 

Source
pub enum WebError {
    NotFound,
    MethodNotAllowed(Vec<&'static str>),
    BadRequest(String),
    PayloadTooLarge,
    TooManyRequests(Option<Duration>),
    Timeout,
    Busy(Option<Duration>),
    Unauthorized,
    Forbidden,
    Internal(String),
    Problem(ProblemDetails),
}
Expand description

An error returned from a handler, a prepare hook, or middleware. Each variant maps to an HTTP status the framework renders as the response (WebError::Problem as an application/problem+json body).

Variants§

§

NotFound

404 Not Found.

§

MethodNotAllowed(Vec<&'static str>)

405. Carries the methods the matched resource does accept, so the response can include the Allow header RFC 7231 §6.5.5 requires. Tokens are the canonical uppercase verb names ("GET", "POST", …); actus-server’s router builds this list, so handlers rarely construct it directly.

§

BadRequest(String)

400 Bad Request. The string is a human-readable reason (e.g. a malformed-body or missing-parameter explanation).

§

PayloadTooLarge

413. The request body exceeded the configured limit (see Server::with_max_body_bytes).

§

TooManyRequests(Option<Duration>)

429. Rate limit exceeded. The optional Duration is the retry-after hint — when present, the framework sets a Retry-After: <seconds> header on the response, per RFC 7231 §7.1.3. Used by an application-supplied rate-limit middleware / prepare hook; the framework itself doesn’t ship a limiter (policy belongs in the application; see the rate-limiting pattern in the README).

§

Timeout

504. The request didn’t complete within the configured timeout (see Server::with_request_timeout). Mapped to 504 Gateway Timeout: the framework is acting as a gateway between the HTTP connection and the handler/middleware stack, and the upstream (handler) didn’t respond in time. Produced by the framework when the per-request timer elapses; handlers can also Err(Timeout) from a downstream call that timed out themselves.

§

Busy(Option<Duration>)

503. The server is overloaded — typically the framework-level concurrency / buffer budget is exhausted (see Server::with_max_inflight_body_bytes). The optional Duration is a retry-after hint; when present, the framework sets a Retry-After: <seconds> header on the response. Distinct from TooManyRequests (429): Busy is “the server is overwhelmed globally,” not “this client has hit its specific limit.”

§

Unauthorized

401 Unauthorized — authentication is missing or invalid.

§

Forbidden

403 Forbidden — authenticated but not permitted.

§

Internal(String)

500 Internal Server Error. The string is logged/returned as the reason; use it for unexpected failures, not for client mistakes.

§

Problem(ProblemDetails)

Structured error with an explicit status code, title, optional detail, and arbitrary extension members. Renders as application/problem+json.

Trait Implementations§

Source§

impl Debug for WebError

Source§

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

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

impl Display for WebError

Source§

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

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

impl Error for WebError

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

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