err-derive

A failure-like derive macro for the std Error. The source code mostly copied from failure-derive.

Features

Usage

Cargo.toml:

toml [dependencies] err-derive = "0.1"

Rust code:

```rust

[macro_use]

extern crate err_derive;

use std::io;

/// MyError::source will return a reference to the io_error field

[derive(Debug, Error)]

[error(display = "An error occurred.")]

struct MyError { #[error(cause)] io_error: io::Error, }

/// MyEnumError::source will return a reference only if it is Variant2, /// otherwise it will return None.

[derive(Debug, Error)]

enum MyEnumError { #[error(display = "An error occurred.")] Variant1, #[error(display = "A different error occurred.")] Variant2(#[error(cause)] io::Error), } ```

License

This project is dual-licensed under Apache-2.0 / MIT. You're free to choose one of both licenses. Every contribution made to this project is assumed to be licensed according to these terms.

See LICENSE, LICENSE-MIT and LICENSE-APACHE for more information.