declare_error_type

Macro declare_error_type 

Source
macro_rules! declare_error_type {
    ($error_kind:ident) => { ... };
}
Expand description

Generate a rich error type using a given error kind.

The type will be called Error. Also generates an ErrorContext trait similar to ErrorContext but specialized for this new error type.

The reason why we cannot define an error type in this crate and export it is because orphan rules would make the ? operator more awkward to use.

§Usage

Define your error kind and then call this macro with that error kind as argument:

declare_error_type!(ErrorKind);

Both the error type and the generated ErrorContext trait will be pub.