mirror of https://github.com/zkat/miette.git
docs: add `severity` example (#350)
Co-authored-by: hzlinyiyu <hzlinyiyu@corp.netease.com>
This commit is contained in:
parent
328bf37922
commit
62cfd221ba
17
README.md
17
README.md
|
|
@ -425,7 +425,7 @@ pub struct MyErrorType {
|
|||
}
|
||||
```
|
||||
|
||||
##### ... help text
|
||||
#### ... help text
|
||||
`miette` provides two facilities for supplying help text for your errors:
|
||||
|
||||
The first is the `#[help()]` format attribute that applies to structs or
|
||||
|
|
@ -461,6 +461,19 @@ let err = Foo {
|
|||
};
|
||||
```
|
||||
|
||||
#### ... severity level
|
||||
`miette` provides a way to set the severity level of a diagnostic.
|
||||
|
||||
```rust
|
||||
use miette::Diagnostic;
|
||||
use thiserror::Error;
|
||||
|
||||
#[derive(Debug, Diagnostic, Error)]
|
||||
#[error("welp")]
|
||||
#[diagnostic(severity(Warning))]
|
||||
struct Foo;
|
||||
```
|
||||
|
||||
#### ... multiple related errors
|
||||
|
||||
`miette` supports collecting multiple errors into a single diagnostic, and
|
||||
|
|
@ -635,7 +648,7 @@ then you may want to use [`miette!`], [`diagnostic!`] macros or
|
|||
|
||||
let source = "2 + 2 * 2 = 8".to_string();
|
||||
let report = miette!(
|
||||
labels = vec[
|
||||
labels = vec![
|
||||
LabeledSpan::at(12..13, "this should be 6"),
|
||||
],
|
||||
help = "'*' has greater precedence than '+'",
|
||||
|
|
|
|||
Loading…
Reference in New Issue