mirror of https://github.com/zkat/miette.git
docs: add docs for #[related]
This commit is contained in:
parent
47e4d4d05c
commit
c337e2759f
21
README.md
21
README.md
|
|
@ -41,6 +41,7 @@ and such might not want.
|
|||
- [... in `main()`](#-in-main)
|
||||
- [... diagnostic code URLs](#-diagnostic-code-urls)
|
||||
- [... snippets](#-snippets)
|
||||
- [... multiple related errors](#-multiple-related-errors)
|
||||
- [... handler options](#-handler-options)
|
||||
- [Acknowledgements](#acknowledgements)
|
||||
- [License](#license)
|
||||
|
|
@ -354,6 +355,26 @@ pub struct MyErrorType {
|
|||
}
|
||||
```
|
||||
|
||||
### ... multiple related errors
|
||||
|
||||
`miette` supports collecting multiple errors into a single diagnostic, and
|
||||
printing them all together nicely.
|
||||
|
||||
To do so, use the `#[related]` tag on any `IntoIter` field in your
|
||||
`Diagnostic` type:
|
||||
|
||||
```rust
|
||||
use miette::Diagnostic;
|
||||
use thiserror::Error;
|
||||
|
||||
#[derive(Debug, Error, Diagnostic)]
|
||||
#[error("oops")]
|
||||
struct MyError {
|
||||
#[related]
|
||||
Vec<MyError>,
|
||||
}
|
||||
```
|
||||
|
||||
### ... handler options
|
||||
|
||||
[MietteHandler] is the default handler, and is very customizable. In most
|
||||
|
|
|
|||
Loading…
Reference in New Issue