Link to err-derive crate

This commit is contained in:
David Tolnay 2019-10-06 09:45:18 -04:00
parent 63cd824139
commit 11a95ca5b0
No known key found for this signature in database
GPG Key ID: F9BA143B95FF6D82
2 changed files with 42 additions and 0 deletions

View File

@ -76,6 +76,26 @@ anyhow = "=1.0.0-alpha.1"
type does not already provide its own. In order to see backtraces, the
`RUST_LIB_BACKTRACE=1` environment variable must be defined.
- Anyhow works with any error type that has an impl of `std::error::Error`,
including ones defined in your crate. We do not bundle a `derive(Error)` macro
but you can write the impls yourself or use a standalone macro like
[err-derive].
[err-derive]: https://crates.io/crates/err-derive
```rust
#[derive(Error, Debug)]
pub enum FormatError {
#[error(display = "invalid header (expected {:?}, got {:?})", expected, found)]
InvalidHeader {
expected: String,
found: String,
},
#[error(display = "missing attribute: {}", _0)]
MissingAttribute(String),
}
```
<br>
## Acknowledgements

View File

@ -124,6 +124,28 @@
//! type does not already provide its own. In order to see backtraces, the
//! `RUST_LIB_BACKTRACE=1` environment variable must be defined.
//!
//! - Anyhow works with any error type that has an impl of `std::error::Error`,
//! including ones defined in your crate. We do not bundle a `derive(Error)`
//! macro but you can write the impls yourself or use a standalone macro like
//! [err-derive].
//!
//! [err-derive]: https://crates.io/crates/err-derive
//!
//! ```
//! # const IGNORE: &str = stringify! {
//! #[derive(Error, Debug)]
//! pub enum FormatError {
//! #[error(display = "invalid header (expected {:?}, got {:?})", expected, found)]
//! InvalidHeader {
//! expected: String,
//! found: String,
//! },
//! #[error(display = "missing attribute: {}", _0)]
//! MissingAttribute(String),
//! }
//! # };
//! ```
//!
//! <br>
//!
//! # Acknowledgements