mirror of
https://github.com/eyre-rs/eyre.git
synced 2025-10-02 15:26:08 +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]
|
[features]
|
||||||
default = ["std"]
|
default = ["std"]
|
||||||
std = []
|
std = []
|
||||||
|
|
||||||
|
[dev-dependencies]
|
||||||
|
thiserror = "1.0"
|
||||||
|
@ -86,14 +86,16 @@ anyhow = "1.0"
|
|||||||
[thiserror]: https://github.com/dtolnay/thiserror
|
[thiserror]: https://github.com/dtolnay/thiserror
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
|
use thiserror::Error;
|
||||||
|
|
||||||
#[derive(Error, Debug)]
|
#[derive(Error, Debug)]
|
||||||
pub enum FormatError {
|
pub enum FormatError {
|
||||||
#[error(display = "invalid header (expected {:?}, got {:?})", expected, found)]
|
#[error("invalid header (expected {expected:?}, got {found:?})")]
|
||||||
InvalidHeader {
|
InvalidHeader {
|
||||||
expected: String,
|
expected: String,
|
||||||
found: String,
|
found: String,
|
||||||
},
|
},
|
||||||
#[error(display = "missing attribute: {}", _0)]
|
#[error("missing attribute: {0}")]
|
||||||
MissingAttribute(String),
|
MissingAttribute(String),
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
@ -132,18 +132,18 @@
|
|||||||
//! [thiserror]: https://github.com/dtolnay/thiserror
|
//! [thiserror]: https://github.com/dtolnay/thiserror
|
||||||
//!
|
//!
|
||||||
//! ```
|
//! ```
|
||||||
//! # const IGNORE: &str = stringify! {
|
//! use thiserror::Error;
|
||||||
|
//!
|
||||||
//! #[derive(Error, Debug)]
|
//! #[derive(Error, Debug)]
|
||||||
//! pub enum FormatError {
|
//! pub enum FormatError {
|
||||||
//! #[error(display = "invalid header (expected {:?}, got {:?})", expected, found)]
|
//! #[error("invalid header (expected {expected:?}, got {found:?})")]
|
||||||
//! InvalidHeader {
|
//! InvalidHeader {
|
||||||
//! expected: String,
|
//! expected: String,
|
||||||
//! found: String,
|
//! found: String,
|
||||||
//! },
|
//! },
|
||||||
//! #[error(display = "missing attribute: {}", _0)]
|
//! #[error("missing attribute: {0}")]
|
||||||
//! MissingAttribute(String),
|
//! MissingAttribute(String),
|
||||||
//! }
|
//! }
|
||||||
//! # };
|
|
||||||
//! ```
|
//! ```
|
||||||
//!
|
//!
|
||||||
//! - One-off error messages can be constructed using the `anyhow!` macro, which
|
//! - One-off error messages can be constructed using the `anyhow!` macro, which
|
||||||
|
Loading…
x
Reference in New Issue
Block a user