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.”
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 Error for WebError
impl Error for WebError
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()