StatusError

Struct 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 Error + Send + Sync>>, pub origin: Option<Box<dyn Any + Send + Sync>>, }
Expand description

HTTP status 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 Error + Send + Sync>>

Cause about http error. Similar to the origin field, but using std::error::Error.

§origin: Option<Box<dyn Any + Send + Sync>>

Origin about http error. Similar to the cause field, but using std::any::Any.

Implementations§

Source§

impl StatusError

Source

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

Sets brief field and returns Self.

Source

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

Sets detail field and returns Self.

Source

pub fn cause<T>(self, cause: T) -> StatusError
where T: Into<Box<dyn Error + Send + Sync>>,

Sets cause field and returns Self.

Source

pub fn origin<T>(self, origin: T) -> StatusError
where T: Send + Sync + 'static,

Sets origin field and returns Self.

Source

pub fn downcast_origin<T>(&self) -> Option<&T>
where T: 'static,

Downcast origin to T

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<(), Error>

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

impl Display for StatusError

Source§

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

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

impl EndpointOutRegister for StatusError

Source§

fn register(components: &mut Components, operation: &mut Operation)

Modify the OpenApi components section or current operation information with given argument. This function is called by macros internal.
Source§

impl Error for StatusError

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

impl ToResponses for StatusError

Source§

fn to_responses(components: &mut Components) -> Responses

Returns an ordered map of response codes to responses.
Source§

impl ToSchema for StatusError

Source§

fn to_schema(components: &mut Components) -> RefOr<Schema>

Returns a tuple of name and schema or reference to a schema that can be referenced by the name or inlined directly to responses, request bodies or parameters.

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

Source§

fn with_context(self, otel_cx: Context) -> WithContext<Self>

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
Source§

fn with_current_context(self) -> WithContext<Self>

Attaches the current Context to this type, returning a WithContext wrapper. Read more
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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToCompactString for T
where T: Display,

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> ToStringFallible for T
where T: Display,

Source§

fn try_to_string(&self) -> Result<String, TryReserveError>

ToString::to_string, but without panic on OOM.

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