pub struct Problem(/* private fields */);
Expand description
Problem
is a reified error type, encoding it’s problem type as a uri.
Implementations§
Source§impl Problem
impl Problem
Sourcepub fn builder() -> ProblemBuilder
pub fn builder() -> ProblemBuilder
Get a new ProblemBuilder
.
Methods from Deref<Target = ApiError>§
Sourcepub fn set_status<T>(&mut self, status: T)where
T: Into<StatusCode>,
pub fn set_status<T>(&mut self, status: T)where
T: Into<StatusCode>,
Set the StatusCode.
Sourcepub fn status(&self) -> StatusCode
pub fn status(&self) -> StatusCode
Get the StatusCode.
Sourcepub fn set_title<T>(&mut self, title: T)where
T: Display,
pub fn set_title<T>(&mut self, title: T)where
T: Display,
This is an optional title which can be used to create a valuable output for consumers.
Sourcepub fn title(&self) -> Option<&str>
pub fn title(&self) -> Option<&str>
This is an optional title which can be used to create a valuable output for consumers.
Sourcepub fn set_message<T>(&mut self, message: T)where
T: Display,
pub fn set_message<T>(&mut self, message: T)where
T: Display,
Set a message that describes the error in a human readable form.
Sourcepub fn message(&self) -> Option<&str>
pub fn message(&self) -> Option<&str>
A message that describes the error in a human readable form.
Sourcepub fn set_type_url<T>(&mut self, type_url: T)where
T: Display,
pub fn set_type_url<T>(&mut self, type_url: T)where
T: Display,
Set 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.
Sourcepub fn type_url(&self) -> Option<&str>
pub fn type_url(&self) -> Option<&str>
A URL that points to a detailed description of the error.
pub fn set_instance<T>(&mut self, instance: T)where
T: Display,
Sourcepub fn instance(&self) -> Option<&str>
pub fn instance(&self) -> Option<&str>
A URL that points to a detailed description of the error.
pub fn set_source<E>(&mut self, source: E)
pub fn set_source_in_a_box<E>(&mut self, source: E)
Sourcepub fn add_field<T, V>(&mut self, name: T, value: V) -> bool
pub fn add_field<T, V>(&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.
Sourcepub fn try_add_field<T, V>(
&mut self,
name: T,
value: V,
) -> Result<(), Box<dyn Error>>
pub fn try_add_field<T, V>( &mut self, name: T, value: V, ) -> Result<(), Box<dyn Error>>
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.
Sourcepub fn fields_mut(&mut self) -> &mut HashMap<String, Value>
pub fn fields_mut(&mut self) -> &mut HashMap<String, Value>
Returns a mutable reference to the serialized fields
Sourcepub fn extensions(&self) -> &Extensions
pub fn extensions(&self) -> &Extensions
Get a reference to the extensions
Extensions will not be part of an HttpApiProblem
Sourcepub fn extensions_mut(&mut self) -> &mut Extensions
pub fn extensions_mut(&mut self) -> &mut Extensions
Get a mutable reference to the extensions
Extensions will not be part of an HttpApiProblem
Sourcepub fn to_http_api_problem(&self) -> HttpApiProblem
pub fn to_http_api_problem(&self) -> HttpApiProblem
Creates an HttpApiProblem from this.
Note: If the status is StatusCode::UNAUTHORIZED fields will not be put into the problem.
Sourcepub fn detail_message(&self) -> Option<Cow<'_, str>>
pub fn detail_message(&self) -> Option<Cow<'_, str>>
If there is a message it will be the message otherwise the source error stringified
If none is present, None
is returned
Trait Implementations§
Source§impl Error for Problem
impl Error for Problem
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
Auto Trait Implementations§
impl Freeze for Problem
impl !RefUnwindSafe for Problem
impl Send for Problem
impl Sync for Problem
impl Unpin for Problem
impl !UnwindSafe for Problem
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string
, but without panic on OOM.