[][src]Struct exonum_rust_runtime::api::Error

#[non_exhaustive]pub struct Error {
    pub http_code: StatusCode,
    pub body: ErrorBody,
    pub headers: HeaderMap,
}

API HTTP error struct.

Fields (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.
http_code: StatusCode

HTTP error code.

body: ErrorBody

API error body.

headers: HeaderMap

Additional HTTP headers.

Methods

impl Error[src]

pub fn new(http_code: StatusCode) -> Error[src]

Builds a ApiError with the given http_code.

pub fn bad_request() -> Error[src]

Builds Bad Request (400) error.

pub fn forbidden() -> Error[src]

Builds Forbidden (403) error.

pub fn not_found() -> Error[src]

Builds Not Found (404) error.

pub fn internal(cause: impl Display) -> Error[src]

Builds Internal Server Error (500).

pub fn docs_uri(self, docs_uri: impl Into<String>) -> Error[src]

Sets docs_uri of an error.

pub fn title(self, title: impl Into<String>) -> Error[src]

Sets title of an error.

pub fn detail(self, detail: impl Into<String>) -> Error[src]

Sets detail of an error.

pub fn error_code(self, error_code: u8) -> Error[src]

Sets error_code of an error.

pub fn parse(http_code: StatusCode, body: &str) -> Result<Error, Error>[src]

Tries to create ApiError from JSON.

Trait Implementations

impl Debug for Error[src]

impl Default for Error[src]

impl Display for Error[src]

impl Error for Error[src]

impl From<MovedPermanentlyError> for Error[src]

impl ResponseError for Error[src]

Auto Trait Implementations

impl RefUnwindSafe for Error

impl Send for Error

impl Sync for Error

impl Unpin for Error

impl UnwindSafe for Error

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> AsFail for T where
    T: Fail, 

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Clear for T where
    T: InitializableFromZeroed + ?Sized

impl<E> Fail for E where
    E: 'static + Error + Send + Sync

impl<T> From<T> for T[src]

impl<T> InitializableFromZeroed for T where
    T: Default

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,