Trait ErrorStacks

Source
pub trait ErrorStacks<C>
where C: Send + Sync + 'static + Eq + PartialEq + Clone,
{ // Required methods fn err_code(&self) -> Option<&C>; fn with_err_code(self, code: C) -> Self; fn with_no_err_code(self) -> Self; fn err_uri(&self) -> Option<&str>; fn with_err_uri(self, uri: String) -> Self; fn with_no_err_uri(self) -> Self; fn with_err_msg(self, error: impl Display + Send + Sync + 'static) -> Self; fn with_no_err_msg(self) -> Self; fn stack_err(self) -> Self; fn stack_err_msg(self, error: impl Display + Send + Sync + 'static) -> Self; }
Expand description

Trait for stacking errors: errors that stack and provide an optional error code and resource URI for runtime error handling.

Required Methods§

Source

fn err_code(&self) -> Option<&C>

Get the error code if one is set.

Source

fn with_err_code(self, code: C) -> Self

Set the error code.

Source

fn with_no_err_code(self) -> Self

Remove the error code.

Source

fn err_uri(&self) -> Option<&str>

Get the error URI if one is set.

Source

fn with_err_uri(self, uri: String) -> Self

Set the error URI.

Source

fn with_no_err_uri(self) -> Self

Remove the error URI.

Source

fn with_err_msg(self, error: impl Display + Send + Sync + 'static) -> Self

Set the error message.

Source

fn with_no_err_msg(self) -> Self

Remove the error message.

Source

fn stack_err(self) -> Self

Stack a new error on the current one.

Source

fn stack_err_msg(self, error: impl Display + Send + Sync + 'static) -> Self

Stack a new error on the current one with a given message.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl<T, E, C> ErrorStacks<C> for Result<T, E>
where C: Send + Sync + 'static + Eq + PartialEq + Clone, E: ErrorStacks<C>,

Implementation for Result allows adding error codes on results.

Source§

fn err_code(&self) -> Option<&C>

Source§

fn with_err_code(self, code: C) -> Self

Source§

fn with_no_err_code(self) -> Self

Source§

fn err_uri(&self) -> Option<&str>

Source§

fn with_err_uri(self, uri: String) -> Self

Source§

fn with_no_err_uri(self) -> Self

Source§

fn with_err_msg(self, error: impl Display + Send + Sync + 'static) -> Self

Source§

fn with_no_err_msg(self) -> Self

Source§

fn stack_err(self) -> Self

Source§

fn stack_err_msg(self, error: impl Display + Send + Sync + 'static) -> Self

Implementors§