derive-error 0.0.2

Derive macro for Error using macros 1.1

Derive Rust Errors

Build Status Latest Version Docs

This crate uses macros 1.1 to derive custom errors.

Getting Started

Add this crate to your dependencies section:-

derive-error = "0.0.2"

Import it in your or

extern crate derive-error;

Deriving errors is simple. Simply create an enum for your errors as suggested in the Rust book, add short descriptions for the enum variants using doc comments, throw in a #[derive(Debug, Error)] and you are done. Here is the example in the book implemented using this library:-

#[derive(Debug, Error)]
enum CliError {
  /// IO Error
  /// Failed to parse the CSV file
  /// No matching cities with a population were found

This will derive implementations for Display, Error and From. See the reql crate for a real world example of how to use this crate.