Struct http_api_problem::ApiError [−][src]
An error that should be returned from an API handler of a web service.
This should be returned from a handler instead of a premature response
or HttpApiProblem. This gives the server a chance for better introspection
on handler errors and also a chance to create a customized response by himself
ApiError requires the feature “api-error” to be enabled.
Fields
message: Option<String>A message that describes the error in a human readable form.
In an HttpApiProblem this becomes the detail in most cases.
If None:
- If there is a cause, this will become the details
- Otherwise there will be no details
status: StatusCodeThe suggested status code for the server to be returned to the client
type_url: Option<String>A URL that points to a detailed description of the error. If not
set it will most probably become httpstatus.es.com/XXX when
the problem response is generated.
fields: HashMap<String, Value>Additional JSON encodable information. It is up to the server how and if it adds the given information.
title: Option<String>This is an optional title which can be used to create a valuable output for consumers.
Implementations
impl ApiError[src]
pub fn builder() -> ApiErrorBuilder[src]
pub fn new<S>(status: S) -> Self where
S: Into<StatusCode>, [src]
S: Into<StatusCode>,
pub fn with_message<S, M>(status: S, message: M) -> Self where
M: Into<String>,
S: Into<StatusCode>, [src]
M: Into<String>,
S: Into<StatusCode>,
pub fn display_message(&self) -> Cow<'_, str>[src]
pub fn add_field<T: Into<String>, V: Serialize>(
&mut self,
name: T,
value: V
) -> bool[src]
&mut self,
name: T,
value: V
) -> bool
Adds a serializable field. If the serialization fails nothing will be
added. This method returns true if the field was added and false if
the field could not be added.
An already present field with the same name will be replaced.
pub fn to_http_api_problem(&self) -> HttpApiProblem[src]
pub fn into_http_api_problem(self) -> HttpApiProblem[src]
pub fn into_hyper_response(self) -> Response<Body>[src]
pub fn into_actix_web_response(self) -> HttpResponse[src]
pub fn into_salvo_response(self) -> Response[src]
impl ApiError[src]
pub fn with_cause<S, E>(status: S, err: E) -> Self where
S: Into<StatusCode>,
E: Error + Send + Sync + 'static, [src]
S: Into<StatusCode>,
E: Error + Send + Sync + 'static,
pub fn with_message_and_cause<S, M, E>(status: S, message: M, err: E) -> Self where
S: Into<StatusCode>,
M: Into<String>,
E: Error + Send + Sync + 'static, [src]
S: Into<StatusCode>,
M: Into<String>,
E: Error + Send + Sync + 'static,
pub fn set_cause<E: Error + Send + Sync + 'static>(&mut self, cause: E)[src]
pub fn try_add_field<T: Into<String>, V: Serialize>(
&mut self,
name: T,
value: V
) -> Result<(), Box<dyn Error + 'static>>[src]
&mut self,
name: T,
value: V
) -> Result<(), Box<dyn Error + 'static>>
Adds a serializable field. If the serialization fails nothing will be added. This fails if a failure occurred while adding the field.
An already present field with the same name will be replaced.
Trait Implementations
impl Debug for ApiError[src]
impl Display for ApiError[src]
impl Error for ApiError[src]
fn source(&self) -> Option<&(dyn Error + 'static)>[src]
pub fn backtrace(&self) -> Option<&Backtrace>[src]
pub fn description(&self) -> &str1.0.0[src]
pub fn cause(&self) -> Option<&dyn Error>1.0.0[src]
impl From<ApiError> for HttpApiProblem[src]
impl From<Error> for ApiError[src]
impl From<Error> for ApiError[src]
impl From<Error> for ApiError[src]
impl From<MailboxError> for ApiError[src]
fn from(error: MailboxError) -> Self[src]
impl From<StatusCode> for ApiError[src]
fn from(s: StatusCode) -> Self[src]
impl Reject for ApiError[src]
impl ResponseError for ApiError[src]
fn error_response(&self) -> HttpResponse[src]
pub fn status_code(&self) -> StatusCode
Auto Trait Implementations
impl !RefUnwindSafe for ApiError
impl Send for ApiError
impl Sync for ApiError
impl Unpin for ApiError
impl !UnwindSafe for ApiError
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T[src]
impl<T> From<T> for T[src]
impl<T> Instrument for T[src]
pub fn instrument(self, span: Span) -> Instrumented<Self>[src]
pub fn in_current_span(self) -> Instrumented<Self>[src]
impl<T> Instrument for T[src]
pub fn instrument(self, span: Span) -> Instrumented<Self>[src]
pub fn in_current_span(self) -> Instrumented<Self>[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T> ToString for T where
T: Display + ?Sized, [src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,
pub fn vzip(self) -> V
impl<T> WithSubscriber for T[src]
pub fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>, [src]
S: Into<Dispatch>,