mirror of
https://github.com/google/comprehensive-rust.git
synced 2025-04-24 16:42:36 +02:00
Merge pull request #49 from ilyagr/patch-1
`anyhow`: Remove `ReadUsernameError::IoError`
This commit is contained in:
commit
9a68434cac
@ -1,7 +1,8 @@
|
|||||||
# Adding Context to Errors
|
# Adding Context to Errors
|
||||||
|
|
||||||
The widely used [anyhow](https://docs.rs/anyhow/) crate can help you add
|
The widely used [anyhow](https://docs.rs/anyhow/) crate can help you add
|
||||||
contextual information to your errors:
|
contextual information to your errors and allows you to have fewer
|
||||||
|
custom error types:
|
||||||
|
|
||||||
```rust,editable,compile_fail
|
```rust,editable,compile_fail
|
||||||
use std::{fs, io};
|
use std::{fs, io};
|
||||||
@ -11,8 +12,6 @@ use anyhow::{Context, Result};
|
|||||||
|
|
||||||
#[derive(Error, Debug)]
|
#[derive(Error, Debug)]
|
||||||
enum ReadUsernameError {
|
enum ReadUsernameError {
|
||||||
#[error("Could not read: {0}")]
|
|
||||||
IoError(#[from] io::Error),
|
|
||||||
#[error("Found no username in {0}")]
|
#[error("Found no username in {0}")]
|
||||||
EmptyUsername(String),
|
EmptyUsername(String),
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user