Struct http_api_problem::ApiErrorBuilder[][src]

pub struct ApiErrorBuilder {
    pub status: StatusCode,
    pub title: Option<String>,
    pub message: Option<String>,
    pub type_url: Option<String>,
    pub instance: Option<String>,
    pub fields: HashMap<String, Value>,
    pub source: Option<Box<dyn Error + Send + Sync + 'static>>,
}

Fields

status: StatusCode

The suggested status code for the server to be returned to the client

title: Option<String>

This is an optional title which can be used to create a valuable output for consumers.

message: Option<String>

A message that describes the error in a human readable form.

In an HttpApiProblem this becomes the detail in most cases.

type_url: Option<String>

A URL that points to a detailed description of the error.

instance: Option<String>

A URI reference that identifies the specific occurrence of the problem. It may or may not yield further information if dereferenced.

fields: HashMap<String, Value>

Additional JSON encodable information. It is up to the server how and if it adds the given information.

source: Option<Box<dyn Error + Send + Sync + 'static>>

Implementations

impl ApiErrorBuilder[src][]

pub fn status<T: Into<StatusCode>>(self, status: T) -> Self[src][]

Set the StatusCode

pub fn try_status<T: TryInto<StatusCode>>(
    self,
    status: T
) -> Result<Self, InvalidStatusCode> where
    T::Error: Into<InvalidStatusCode>, 
[src][]

Try to set the StatusCode

Fails if the status argument can not be converted to a StatusCode

pub fn title<T: Display>(self, title: T) -> Self[src][]

This is an optional title which can be used to create a valuable output for consumers.

pub fn message<M: Display>(self, message: M) -> Self[src][]

A message that describes the error in a human readable form.

In an HttpApiProblem this becomes the detail in most cases.

pub fn type_url<U: Display>(self, type_url: U) -> Self[src][]

A URL that points to a detailed description of the error.

pub fn instance<T: Display>(self, instance: T) -> Self[src][]

Sets the instance

A URI reference that identifies the specific occurrence of the problem. It may or may not yield further information if dereferenced.

pub fn field<T: Into<String>, V: Serialize>(self, name: T, value: V) -> Self[src][]

Adds a serializable field.

If the serialization fails nothing will be added. An already present field with the same name will be replaced.

pub fn source<E: Error + Send + Sync + 'static>(self, source: E) -> Self[src]

pub fn source_in_a_box<E: Into<Box<dyn Error + Send + Sync + 'static>>>(
    self,
    source: E
) -> Self
[src]

pub fn finish(self) -> ApiError[src][]

Build the ApiError

Trait Implementations

Auto Trait Implementations

Blanket Implementations

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

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

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

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

impl<T> Instrument for T[src][+]

impl<T> Instrument for T[src][+]

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

impl<T> Same<T> for T

type Output = T

Should always be Self

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>, 
[+]

impl<T> WithSubscriber for T[src][+]