pub struct NeuErr(/* private fields */);Expand description
Generic rich error type for use within Results, for libraries and applications.
Add human context information, including code locations, via the context method.
Attach machine context information via the attach and attach_override methods.
§Error Formatting
The normal Debug implementation ("{err:?}") will print the error with multi-line formatting,
exactly how Display is doing it. The alternate Debug implementation ("{err:#?}") will show
the pretty-printed usual debug representation of the internal types.
When using the Display implementation, the normal implementation ("{err}") will use
multi-line formatting. You can use the alternate format ({err:#}) to get a compact single-line
version. instead of multi-line formatted.
Implementations§
Source§impl NeuErr
impl NeuErr
Sourcepub fn new_with_source<C, E>(context: C, source: E) -> Self
pub fn new_with_source<C, E>(context: C, source: E) -> Self
Create new error from source error.
Sourcepub fn from_source<E>(source: E) -> Selfwhere
E: ErrorSendSync + 'static,
pub fn from_source<E>(source: E) -> Selfwhere
E: ErrorSendSync + 'static,
Convert source error.
Sourcepub fn attach<C>(self, context: C) -> Selfwhere
C: AnyDebugSendSync + 'static,
pub fn attach<C>(self, context: C) -> Selfwhere
C: AnyDebugSendSync + 'static,
Add machine context to the error.
This will not override existing attachments. If you want to replace and override any
existing attachments of the same type, use attach_override instead.
Sourcepub fn attach_override<C>(self, context: C) -> Selfwhere
C: AnyDebugSendSync + 'static,
pub fn attach_override<C>(self, context: C) -> Selfwhere
C: AnyDebugSendSync + 'static,
Set machine context in the error.
This will override existing attachments of the same type. If you want to add attachments of
the same type, use attach instead.
Sourcepub fn attachments<C>(&self) -> impl Iterator<Item = &C>where
C: AnyDebugSendSync + 'static,
pub fn attachments<C>(&self) -> impl Iterator<Item = &C>where
C: AnyDebugSendSync + 'static,
Get an iterator over the machine context attachments of the given type.
Sourcepub fn attachment<C>(&self) -> Option<&C>where
C: AnyDebugSendSync + 'static,
pub fn attachment<C>(&self) -> Option<&C>where
C: AnyDebugSendSync + 'static,
Get the machine context attachment of the given type.
Sourcepub fn into_error(self) -> NeuErrImpl
pub fn into_error(self) -> NeuErrImpl
Unwrap this error into a NeuErrImpl that implements Error. Note however, that it
does not offer all of the functionality and might be unwieldy for other general purposes
than interfacing with other error types.
Trait Implementations§
Source§impl AsRef<dyn Error + Send + Sync> for NeuErr
Available on crate features send and sync only.
impl AsRef<dyn Error + Send + Sync> for NeuErr
send and sync only.Source§impl From<NeuErr> for Box<dyn Error + Send + Sync>
Available on crate features send and sync only.
impl From<NeuErr> for Box<dyn Error + Send + Sync>
send and sync only.