Struct salvo_core::http::errors::StatusError

source ·
#[non_exhaustive]
pub struct StatusError { pub code: StatusCode, pub name: String, pub brief: String, pub detail: Option<String>, pub cause: Option<Box<dyn StdError + Sync + Send + 'static>>, }
Expand description

StatusError contains http error information.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§code: StatusCode

Http error status code.

§name: String

Http error name.

§brief: String

Brief information about http error.

§detail: Option<String>

Detail information about http error.

§cause: Option<Box<dyn StdError + Sync + Send + 'static>>

Cause about http error. This field is only used for internal debugging and only used in debug mode.

Implementations§

source§

impl StatusError

source

pub fn brief(self, brief: impl Into<String>) -> Self

Sets brief field and returns Self.

source

pub fn detail(self, detail: impl Into<String>) -> Self

Sets detail field and returns Self.

source

pub fn cause<C>(self, cause: C) -> Self
where C: Into<Box<dyn StdError + Sync + Send + 'static>>,

Sets cause field and returns Self.

source

pub fn bad_request() -> StatusError

The request could not be understood by the server due to malformed syntax.

400 Bad Request [RFC7231, Section 6.5.1]

source

pub fn unauthorized() -> StatusError

The request requires user authentication.

401 Unauthorized [RFC7235, Section 3.1]

source

pub fn payment_required() -> StatusError

The request could not be processed due to lack of payment.

402 Payment Required [RFC7231, Section 6.5.2]

source

pub fn forbidden() -> StatusError

The server refused to authorize the request.

403 Forbidden [RFC7231, Section 6.5.3]

source

pub fn not_found() -> StatusError

The requested resource could not be found.

404 Not Found [RFC7231, Section 6.5.4]

source

pub fn method_not_allowed() -> StatusError

The request method is not supported for the requested resource.

405 Method Not Allowed [RFC7231, Section 6.5.5]

source

pub fn not_acceptable() -> StatusError

The requested resource is capable of generating only content not acceptable according to the Accept headers sent in the request.

406 Not Acceptable [RFC7231, Section 6.5.6]

source

pub fn proxy_authentication_required() -> StatusError

Authentication with the proxy is required.

407 Proxy Authentication Required [RFC7235, Section 3.2]

source

pub fn request_timeout() -> StatusError

The server timed out waiting for the request.

408 Request Timeout [RFC7231, Section 6.5.7]

source

pub fn conflict() -> StatusError

The request could not be processed because of a conflict in the request.

409 Conflict [RFC7231, Section 6.5.8]

source

pub fn gone() -> StatusError

The resource requested is no longer available and will not be available again.

410 Gone [RFC7231, Section 6.5.9]

source

pub fn length_required() -> StatusError

The request did not specify the length of its content, which is required by the requested resource.

411 Length Required [RFC7231, Section 6.5.10]

source

pub fn precondition_failed() -> StatusError

The server does not meet one of the preconditions specified in the request.

412 Precondition Failed [RFC7232, Section 4.2]

source

pub fn payload_too_large() -> StatusError

The request is larger than the server is willing or able to process.

413 Payload Too Large [RFC7231, Section 6.5.11]

source

pub fn uri_too_long() -> StatusError

The URI provided was too long for the server to process.

414 URI Too Long [RFC7231, Section 6.5.12]

source

pub fn unsupported_media_type() -> StatusError

The request entity has a media type which the server or resource does not support.

415 Unsupported Media Type [RFC7231, Section 6.5.13]

source

pub fn range_not_satisfiable() -> StatusError

The portion of the requested file cannot be supplied by the server.

416 Range Not Satisfiable [RFC7233, Section 4.4]

source

pub fn expectation_failed() -> StatusError

The server cannot meet the requirements of the expect request-header field.

417 Expectation Failed [RFC7231, Section 6.5.14]

source

pub fn im_a_teapot() -> StatusError

I was requested to brew coffee, and I am a teapot.

418 I’m a teapot [curiously not registered by IANA but RFC2324]

source

pub fn misdirected_request() -> StatusError

The server cannot produce a response for this request.

421 Misdirected Request RFC7540, Section 9.1.2

source

pub fn unprocessable_entity() -> StatusError

The request was well-formed but was unable to be followed due to semantic errors.

422 Unprocessable Entity [RFC4918]

source

pub fn locked() -> StatusError

The source or destination resource of a method is locked.

423 Locked [RFC4918]

source

pub fn failed_dependency() -> StatusError

The method could not be performed on the resource because the requested action depended on another action and that action failed.

424 Failed Dependency [RFC4918]

source

pub fn upgrade_required() -> StatusError

Switching to the protocol in the Upgrade header field is required.

426 Upgrade Required [RFC7231, Section 6.5.15]

source

pub fn precondition_required() -> StatusError

The server requires the request to be conditional.

428 Precondition Required [RFC6585]

source

pub fn too_many_requests() -> StatusError

Too many requests have been received recently.

429 Too Many Requests [RFC6585]

source

pub fn request_header_fields_toolarge() -> StatusError

The server is unwilling to process the request because either an individual header field, or all the header fields collectively, are too large.

431 Request Header Fields Too Large [RFC6585]

source

pub fn unavailable_for_legalreasons() -> StatusError

The requested resource is unavailable due to a legal demand to deny access to this resource.

451 Unavailable For Legal Reasons [RFC7725]

source

pub fn internal_server_error() -> StatusError

The server encountered an internal error while processing this request.

500 Internal Server Error [RFC7231, Section 6.6.1]

source

pub fn not_implemented() -> StatusError

The server either does not recognize the request method, or it lacks the ability to fulfill the request.

501 Not Implemented [RFC7231, Section 6.6.2]

source

pub fn bad_gateway() -> StatusError

Received an invalid response from an inbound server it accessed while attempting to fulfill the request.

502 Bad Gateway [RFC7231, Section 6.6.3]

source

pub fn service_unavailable() -> StatusError

The server is currently unavailable.

503 Service Unavailable [RFC7231, Section 6.6.4]

source

pub fn gateway_timeout() -> StatusError

The server did not receive a timely response from an upstream server.

504 Gateway Timeout [RFC7231, Section 6.6.5]

source

pub fn http_version_not_supported() -> StatusError

The server does not support, or refuses to support, the major version of HTTP that was used in the request message.

505 HTTP Version Not Supported [RFC7231, Section 6.6.6]

source

pub fn variant_also_negotiates() -> StatusError

The server has an internal configuration error.

506 Variant Also Negotiates [RFC2295]

source

pub fn insufficient_storage() -> StatusError

The method could not be performed on the resource because the server is unable to store the representation needed to successfully complete the request.

507 Insufficient Storage [RFC4918]

source

pub fn loop_detected() -> StatusError

the server terminated an operation because it encountered an infinite loop while processing a request with “Depth: infinity”.

508 Loop Detected [RFC5842]

source

pub fn not_extended() -> StatusError

Further extensions to the request are required for the server to fulfill it.

510 Not Extended [RFC2774]

source

pub fn network_authentication_required() -> StatusError

the client needs to authenticate to gain network access.

511 Network Authentication Required [RFC6585]

source§

impl StatusError

source

pub fn from_code(code: StatusCode) -> Option<StatusError>

Create new StatusError with code. If code is not error, it will be None.

Trait Implementations§

source§

impl Debug for StatusError

source§

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

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

impl Display for StatusError

source§

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

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

impl Error for StatusError

1.30.0 · source§

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

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 From<StatusError> for Error

source§

fn from(e: StatusError) -> Error

Converts to this type from the input type.
source§

impl Scribe for StatusError

source§

fn render(self, res: &mut Response)

Render data to Response.

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<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

source§

fn implicit( self, class: Class, constructed: bool, tag: u32 ) -> TaggedParser<'a, Implicit, Self, E>

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> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToString for T
where T: Display + ?Sized,

source§

default 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>,

§

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

§

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<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

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
source§

impl<P> Writer for P
where P: Scribe + Send,

source§

fn write<'life0, 'life1, 'life2, 'async_trait>( self, _req: &'life0 mut Request, _depot: &'life1 mut Depot, res: &'life2 mut Response ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, P: 'async_trait,

Write data to Response.
source§

impl<T> CacheError for T
where T: Error + Send + Sync + 'static,