| Status: | production-ready |
|---|---|
| Documentation: | https://docs.rs/quick-error/ |
A macro which makes error types pleasant to write.
Features:
- Define enum type with arbitrary parameters
- Concise notation of
DisplayandErrortraits - Full control of
DisplayandErrortrait implementation - Any number of
Fromtraits - Support for all enum-variants
Unit,TupleandStruct
Here is the comprehensive example:
quick_error!{
#[derive(Debug)]pubenumIoWrapper{Io(err: io::Error){
from()
display("I/O error: {}", err)
source(err)}Other(descr:&'staticstr){
display("Error {}", descr)}IoAt{ place:&'staticstr, err: io::Error}{
source(err)
display(me) -> ("io error at {}: {}", place, err)
from(s:String) -> {
place:"some string",
err: io::Error::new(io::ErrorKind::Other, s)}}Discard{
from(&'staticstr)}}}Licensed under either of
- Apache License, Version 2.0, (./LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (./LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
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.