mirror of
https://github.com/eyre-rs/eyre.git
synced 2025-09-28 21:41:58 +00:00
Pull in thiserror library for tests
This commit is contained in:
parent
d4bc68cf65
commit
a37dea2133
@ -12,3 +12,6 @@ readme = "README.md"
|
||||
[features]
|
||||
default = ["std"]
|
||||
std = []
|
||||
|
||||
[dev-dependencies]
|
||||
thiserror = "1.0"
|
||||
|
@ -86,14 +86,16 @@ anyhow = "1.0"
|
||||
[thiserror]: https://github.com/dtolnay/thiserror
|
||||
|
||||
```rust
|
||||
use thiserror::Error;
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
pub enum FormatError {
|
||||
#[error(display = "invalid header (expected {:?}, got {:?})", expected, found)]
|
||||
#[error("invalid header (expected {expected:?}, got {found:?})")]
|
||||
InvalidHeader {
|
||||
expected: String,
|
||||
found: String,
|
||||
},
|
||||
#[error(display = "missing attribute: {}", _0)]
|
||||
#[error("missing attribute: {0}")]
|
||||
MissingAttribute(String),
|
||||
}
|
||||
```
|
||||
|
@ -132,18 +132,18 @@
|
||||
//! [thiserror]: https://github.com/dtolnay/thiserror
|
||||
//!
|
||||
//! ```
|
||||
//! # const IGNORE: &str = stringify! {
|
||||
//! use thiserror::Error;
|
||||
//!
|
||||
//! #[derive(Error, Debug)]
|
||||
//! pub enum FormatError {
|
||||
//! #[error(display = "invalid header (expected {:?}, got {:?})", expected, found)]
|
||||
//! #[error("invalid header (expected {expected:?}, got {found:?})")]
|
||||
//! InvalidHeader {
|
||||
//! expected: String,
|
||||
//! found: String,
|
||||
//! },
|
||||
//! #[error(display = "missing attribute: {}", _0)]
|
||||
//! #[error("missing attribute: {0}")]
|
||||
//! MissingAttribute(String),
|
||||
//! }
|
||||
//! # };
|
||||
//! ```
|
||||
//!
|
||||
//! - One-off error messages can be constructed using the `anyhow!` macro, which
|
||||
|
Loading…
x
Reference in New Issue
Block a user