NeuErr

Struct NeuErr 

Source
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

Source

pub fn new<C>(context: C) -> Self
where C: Into<Cow<'static, str>>,

Create new error.

Source

pub fn new_with_source<C, E>(context: C, source: E) -> Self
where C: Into<Cow<'static, str>>, E: ErrorSendSync + 'static,

Create new error from source error.

Source

pub fn from_source<E>(source: E) -> Self
where E: ErrorSendSync + 'static,

Convert source error.

Source

pub fn context<C>(self, context: C) -> Self
where C: Into<Cow<'static, str>>,

Add human context to the error.

Source

pub fn attach<C>(self, context: C) -> Self
where 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.

Source

pub fn attach_override<C>(self, context: C) -> Self
where 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.

Source

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.

Source

pub fn attachment<C>(&self) -> Option<&C>
where C: AnyDebugSendSync + 'static,

Get the machine context attachment of the given type.

Source

pub fn source(&self) -> Option<&(dyn ErrorSendSync + 'static)>

Get the source error.

Source

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> for NeuErr

Source§

fn as_ref(&self) -> &(dyn Error + 'static)

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<dyn Error + Send> for NeuErr

Available on crate feature send only.
Source§

fn as_ref(&self) -> &(dyn Error + Send + 'static)

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<dyn Error + Send + Sync> for NeuErr

Available on crate features send and sync only.
Source§

fn as_ref(&self) -> &(dyn Error + Send + Sync + 'static)

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Debug for NeuErr

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> FmtResult

Formats the value using the given formatter. Read more
Source§

impl Default for NeuErr

Source§

fn default() -> NeuErr

Returns the “default value” for a type. Read more
Source§

impl Display for NeuErr

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> FmtResult

Formats the value using the given formatter. Read more
Source§

impl<E> From<E> for NeuErr
where E: ErrorSendSync + 'static,

Source§

fn from(err: E) -> Self

Converts to this type from the input type.
Source§

impl From<NeuErr> for Box<dyn Error>

Source§

fn from(this: NeuErr) -> Self

Converts to this type from the input type.
Source§

impl From<NeuErr> for Box<dyn Error + Send>

Available on crate feature send only.
Source§

fn from(this: NeuErr) -> Self

Converts to this type from the input type.
Source§

impl From<NeuErr> for Box<dyn Error + Send + Sync>

Available on crate features send and sync only.
Source§

fn from(this: NeuErr) -> Self

Converts to this type from the input type.
Source§

impl From<NeuErr> for NeuErrImpl

Source§

fn from(err: NeuErr) -> Self

Converts to this type from the input type.
Source§

impl Termination for NeuErr

Available on crate feature std only.
Source§

fn report(self) -> ExitCode

Is called to get the representation of the value as status code. This status code is returned to the operating system.

Auto Trait Implementations§

§

impl Freeze for NeuErr

§

impl !RefUnwindSafe for NeuErr

§

impl Send for NeuErr

§

impl Sync for NeuErr

§

impl Unpin for NeuErr

§

impl !UnwindSafe for NeuErr

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<!> for T

Source§

fn from(t: !) -> T

Converts to this type from the input type.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.