[][src]Struct witcher::Error

pub struct Error { /* fields omitted */ }

Error is a wrapper providing additional context and chaining of errors.

Error provides the following benefits

  • ensures a backtrace will be taken at the earliest opportunity
  • ensures that the error type is threadsafe and has a static lifetime
  • provides matching on inner error types

Context comes in two forms. First every time an error is wrapped you have the opportunity to add an additional message. Finally a simplified stack trace is automatically provided that narrows in on your actual code ignoring the wind up and wind down that resides in the Rust std libraries and other dependencies allowing you to focus on your code.

Saftey: data layout ensured to be consistent with repr(C) for raw conversions.

Implementations

impl Error[src]

pub fn raw(msg: &str) -> Self[src]

Create a new error instance wrapped in a result

pub fn wrapr<E>(err: E, msg: &str) -> Self where
    E: StdError + Send + Sync + 'static, 
[src]

Wrap the given error and include a contextual message for the error.

pub fn new<T>(msg: &str) -> Result<T>[src]

Create a new error instance wrapped in a result

pub fn wrap<T, E>(err: E, msg: &str) -> Result<T> where
    E: StdError + Send + Sync + 'static, 
[src]

Wrap the given error and include a contextual message for the error.

pub fn ext(&self) -> &(dyn StdError + 'static)[src]

Return the first external error of the error chain for downcasting. The intent is that when writing application code there are cases where your more interested in reacting to an external failure. If there is no external error then you'll get the last Error in the chain.

pub fn last(&self) -> &(dyn StdError + 'static)[src]

Return the last of the error chain for downcasting. This will follow the chain of source errors down to the last and return it. If this error is the only error it will be returned instead.

pub fn is<T: StdError + 'static>(&self) -> bool[src]

Implemented directly on the Error type to reduce casting required

pub fn downcast_ref<T: StdError + 'static>(&self) -> Option<&T>[src]

Implemented directly on the Error type to reduce casting required

pub fn downcast_mut<T: StdError + 'static>(&mut self) -> Option<&mut T>[src]

Implemented directly on the Error type to reduce casting required

pub fn source(&self) -> Option<&(dyn StdError + 'static)>[src]

Implemented directly on the Error type to reduce casting required

Trait Implementations

impl AsRef<dyn Error + 'static> for Error[src]

impl Debug for Error[src]

Provides the same formatting for output as Display but includes the fullstack trace.

impl Display for Error[src]

Provides formatting for output with frames filtered to just target code

impl Error for Error[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.