pub struct Problem {
pub causes: ThinVec<Cause>,
}Expand description
A problem is a simple wrapper for an error causation chain.
Each link in the chain is a Cause, which is itself a simple wrapper for a CapturedError. Each cause can have any number of attachments.
Though you can iterate a problem directly to access its causes, often it is easier to use one of the many convenience functions in the ProblemImplementation and Causes traits.
Note that this type does not itself implement Error directly, but you can use into_error if compatibility is needed.
For more information and usage examples see the Problemo home page.
Fields§
§causes: ThinVec<Cause>Causes in order of causation from top to root.
Implementations§
Source§impl Problem
impl Problem
Sourcepub fn new(error: CapturedError) -> Self
pub fn new(error: CapturedError) -> Self
Constructor.
Sourcepub fn into_error(self) -> ProblemAsError
pub fn into_error(self) -> ProblemAsError
Sourcepub fn via<ErrorT>(self, error: ErrorT) -> Self
pub fn via<ErrorT>(self, error: ErrorT) -> Self
Adds the error to the top of the causation chain.
Sourcepub fn with_once<AttachmentT>(self, attachment: AttachmentT) -> Self
pub fn with_once<AttachmentT>(self, attachment: AttachmentT) -> Self
Attach only if we don’t already have one of the same type.
Sourcepub fn maybe_with<AttachmentT>(self, attachment: Option<AttachmentT>) -> Self
pub fn maybe_with<AttachmentT>(self, attachment: Option<AttachmentT>) -> Self
Attach to the top cause if Some.
Sourcepub fn maybe_with_once<AttachmentT>(
self,
attachment: Option<AttachmentT>,
) -> Self
pub fn maybe_with_once<AttachmentT>( self, attachment: Option<AttachmentT>, ) -> Self
Attach to the top cause if Some and we don’t already have one of the same type.
Sourcepub fn with_location(self) -> Self
pub fn with_location(self) -> Self
Attach a Location (via Location::caller) if we don’t already have one.
Sourcepub fn with_backtrace(self) -> Self
pub fn with_backtrace(self) -> Self
Attach a backtrace if we don’t already have one.
Trait Implementations§
Source§impl Attachments for Problem
impl Attachments for Problem
Source§fn attachments(&self) -> impl Iterator<Item = &CapturedAttachment>
fn attachments(&self) -> impl Iterator<Item = &CapturedAttachment>
Source§fn attachments_of_type<'this, AttachmentT>(
&'this self,
) -> impl Iterator<Item = &'this AttachmentT>where
AttachmentT: 'static,
fn attachments_of_type<'this, AttachmentT>(
&'this self,
) -> impl Iterator<Item = &'this AttachmentT>where
AttachmentT: 'static,
Source§fn attachment_of_type<AttachmentT>(&self) -> Option<&AttachmentT>where
AttachmentT: 'static,
fn attachment_of_type<AttachmentT>(&self) -> Option<&AttachmentT>where
AttachmentT: 'static,
Source§impl AttachmentsMut for Problem
impl AttachmentsMut for Problem
Source§fn attachments_mut(&mut self) -> impl Iterator<Item = &mut CapturedAttachment>
fn attachments_mut(&mut self) -> impl Iterator<Item = &mut CapturedAttachment>
Source§fn attachments_of_type_mut<'this, AttachmentT>(
&'this mut self,
) -> impl Iterator<Item = &'this mut AttachmentT>where
AttachmentT: 'static,
fn attachments_of_type_mut<'this, AttachmentT>(
&'this mut self,
) -> impl Iterator<Item = &'this mut AttachmentT>where
AttachmentT: 'static,
Source§fn attachment_of_type_mut<AttachmentT>(&mut self) -> Option<&mut AttachmentT>where
AttachmentT: 'static,
fn attachment_of_type_mut<AttachmentT>(&mut self) -> Option<&mut AttachmentT>where
AttachmentT: 'static,
Source§fn must_attachment_of_type_mut<AttachmentT, DefaultT>(
&mut self,
default: DefaultT,
) -> &mut AttachmentT
fn must_attachment_of_type_mut<AttachmentT, DefaultT>( &mut self, default: DefaultT, ) -> &mut AttachmentT
Source§fn attach_once<AttachmentT>(&mut self, attachment: AttachmentT)
fn attach_once<AttachmentT>(&mut self, attachment: AttachmentT)
Source§fn attach_location_once(&mut self)
fn attach_location_once(&mut self)
Source§fn attach_backtrace_once(&mut self)
fn attach_backtrace_once(&mut self)
backtrace-external only.Source§impl Causes for Problem
impl Causes for Problem
Source§fn iter_causes(&self) -> impl Iterator<Item = &Cause>
fn iter_causes(&self) -> impl Iterator<Item = &Cause>
Source§fn iter_causes_with_error_type<ErrorT>(
&self,
) -> impl Iterator<Item = CauseRef<'_, ErrorT>>where
ErrorT: 'static + Error,
fn iter_causes_with_error_type<ErrorT>(
&self,
) -> impl Iterator<Item = CauseRef<'_, ErrorT>>where
ErrorT: 'static + Error,
Source§fn iter_causes_until_error_type<ErrorT>(&self) -> impl Iterator<Item = &Cause>where
ErrorT: 'static + Error,
fn iter_causes_until_error_type<ErrorT>(&self) -> impl Iterator<Item = &Cause>where
ErrorT: 'static + Error,
Source§fn iter_causes_from_error_type<ErrorT>(&self) -> impl Iterator<Item = &Cause>where
ErrorT: 'static + Error,
fn iter_causes_from_error_type<ErrorT>(&self) -> impl Iterator<Item = &Cause>where
ErrorT: 'static + Error,
Source§fn iter_causes_with_error<ErrorT>(
&self,
error: &ErrorT,
) -> impl Iterator<Item = CauseRef<'_, ErrorT>>
fn iter_causes_with_error<ErrorT>( &self, error: &ErrorT, ) -> impl Iterator<Item = CauseRef<'_, ErrorT>>
Source§fn iter_causes_with_attachment_type<AttachmentT>(
&self,
) -> impl Iterator<Item = (&Cause, &AttachmentT)>where
AttachmentT: 'static,
fn iter_causes_with_attachment_type<AttachmentT>(
&self,
) -> impl Iterator<Item = (&Cause, &AttachmentT)>where
AttachmentT: 'static,
Source§fn cause_with_error_type<ErrorT>(&self) -> Option<CauseRef<'_, ErrorT>>where
ErrorT: 'static + Error,
fn cause_with_error_type<ErrorT>(&self) -> Option<CauseRef<'_, ErrorT>>where
ErrorT: 'static + Error,
Source§fn cause_with_error<ErrorT>(
&self,
error: &ErrorT,
) -> Option<CauseRef<'_, ErrorT>>
fn cause_with_error<ErrorT>( &self, error: &ErrorT, ) -> Option<CauseRef<'_, ErrorT>>
Source§fn cause_with_attachment_type<AttachmentT>(
&self,
) -> Option<(&Cause, &AttachmentT)>where
AttachmentT: 'static,
fn cause_with_attachment_type<AttachmentT>(
&self,
) -> Option<(&Cause, &AttachmentT)>where
AttachmentT: 'static,
Source§fn iter_errors(&self) -> impl Iterator<Item = &CapturedError>
fn iter_errors(&self) -> impl Iterator<Item = &CapturedError>
Source§fn iter_errors_of_type<ErrorT>(&self) -> impl Iterator<Item = &ErrorT>where
ErrorT: 'static + Error,
fn iter_errors_of_type<ErrorT>(&self) -> impl Iterator<Item = &ErrorT>where
ErrorT: 'static + Error,
Source§fn error_of_type<ErrorT>(&self) -> Option<&ErrorT>where
ErrorT: 'static + Error,
fn error_of_type<ErrorT>(&self) -> Option<&ErrorT>where
ErrorT: 'static + Error,
Source§impl From<Problem> for ProblemAsError
impl From<Problem> for ProblemAsError
Source§impl From<Problem> for SerdeProblem
Available on crate feature serde only.
impl From<Problem> for SerdeProblem
serde only.Source§impl FromIterator<Problem> for Problems
impl FromIterator<Problem> for Problems
Source§impl<'this> IntoIterator for &'this Problem
Available on crate feature thin-vec only.
impl<'this> IntoIterator for &'this Problem
thin-vec only.Source§impl<'this> IntoIterator for &'this mut Problem
Available on crate feature thin-vec only.
impl<'this> IntoIterator for &'this mut Problem
thin-vec only.Source§impl IntoIterator for Problem
Available on crate feature thin-vec only.
impl IntoIterator for Problem
thin-vec only.Source§impl IntoProblem for Problem
impl IntoProblem for Problem
Source§fn into_problem(self) -> Problem
fn into_problem(self) -> Problem
Source§impl PartialOrd for Problem
impl PartialOrd for Problem
Source§impl ProblemImplementation for Problem
Available on crate feature thin-vec only.
impl ProblemImplementation for Problem
thin-vec only.