Skip to content

Commit

Permalink
Tweak readme's mention of bail
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Oct 26, 2020
1 parent da3e403 commit 45555cc
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,15 @@ anyhow = "1.0"
```

- One-off error messages can be constructed using the `anyhow!` macro, which
supports string interpolation and produces an `anyhow::Error`. Use `bail!` as
shorthand to return early with an error.
supports string interpolation and produces an `anyhow::Error`.

```rust
return Err(anyhow!("Missing attribute: {}", missing));
// or
```

A `bail!` macro is provided as a shorthand for the same early return.

```rust
bail!("Missing attribute: {}", missing);
```

Expand Down

0 comments on commit 45555cc

Please sign in to comment.