Skip to content
A rust-macro which makes errors easy to write
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
examples context2: Fix namespacing of `Context` May 17, 2016
src Silence deprecation warning Jan 5, 2019
.gitignore Initial quick_error macro Sep 9, 2015
.travis.yml Updates travis config, adds packaging stuff Sep 6, 2017
Cargo.toml Version bumped to v1.2.2 May 26, 2018
LICENSE-APACHE Relicense to dual MIT/Apache-2.0 Jan 11, 2016
LICENSE-MIT
README.rst
bulk.yaml Updates travis config, adds packaging stuff Sep 6, 2017
vagga.yaml Updates travis config, adds packaging stuff Sep 6, 2017

README.rst

Quick Error

Status:production-ready
Documentation:http://tailhook.github.io/quick-error/

A macro which makes error types pleasant to write.

Features:

  • Define enum type with arbitrary parameters
  • Concise notation of Display and Error traits
  • Full control of Display and Error trait implementation
  • Any number of From traits
  • Support for all enum-variants Unit, Tuple and Struct

Here is the comprehensive example:

quick_error! {
    #[derive(Debug)]
    pub enum IoWrapper {
        Io(err: io::Error) {
            from()
            description("io error")
            display("I/O error: {}", err)
            cause(err)
        }
        Other(descr: &'static str) {
            description(descr)
            display("Error {}", descr)
        }
        IoAt { place: &'static str, err: io::Error } {
            cause(err)
            display(me) -> ("{} {}: {}", me.description(), place, err)
            description("io error at")
            from(s: String) -> {
                place: "some string",
                err: io::Error::new(io::ErrorKind::Other, s)
            }
        }
        Discard {
            from(&'static str)
        }
    }
}

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

You can’t perform that action at this time.