mirror of https://github.com/zkat/miette.git
doc: add `severity` example
This commit is contained in:
parent
6ea86a2248
commit
c3a0781e3e
56
README.md
56
README.md
|
|
@ -34,24 +34,29 @@ libraries and such might not want.
|
||||||
|
|
||||||
### Table of Contents <!-- omit in toc -->
|
### Table of Contents <!-- omit in toc -->
|
||||||
|
|
||||||
- [About](#about)
|
- [`miette`](#miette)
|
||||||
- [Features](#features)
|
- [About](#about)
|
||||||
- [Installing](#installing)
|
- [Features](#features)
|
||||||
- [Example](#example)
|
- [Installing](#installing)
|
||||||
- [Using](#using)
|
- [Example](#example)
|
||||||
- [... in libraries](#-in-libraries)
|
- [Using](#using)
|
||||||
- [... in application code](#-in-application-code)
|
- [... in libraries](#-in-libraries)
|
||||||
- [... in `main()`](#-in-main)
|
- [... in application code](#-in-application-code)
|
||||||
- [... diagnostic code URLs](#-diagnostic-code-urls)
|
- [... in `main()`](#-in-main)
|
||||||
- [... snippets](#-snippets)
|
- [... diagnostic code URLs](#-diagnostic-code-urls)
|
||||||
- [... multiple related errors](#-multiple-related-errors)
|
- [... snippets](#-snippets)
|
||||||
- [... delayed source code](#-delayed-source-code)
|
- [... help text](#-help-text)
|
||||||
- [... handler options](#-handler-options)
|
- [... severity level](#-severity-level)
|
||||||
- [... dynamic diagnostics](#-dynamic-diagnostics)
|
- [... multiple related errors](#-multiple-related-errors)
|
||||||
- [... syntax highlighting](#-syntax-highlighting)
|
- [... delayed source code](#-delayed-source-code)
|
||||||
- [... collection of labels](#-collection-of-labels)
|
- [... Diagnostic-based error sources.](#-diagnostic-based-error-sources)
|
||||||
- [Acknowledgements](#acknowledgements)
|
- [... handler options](#-handler-options)
|
||||||
- [License](#license)
|
- [... dynamic diagnostics](#-dynamic-diagnostics)
|
||||||
|
- [... syntax highlighting](#-syntax-highlighting)
|
||||||
|
- [... collection of labels](#-collection-of-labels)
|
||||||
|
- [MSRV](#msrv)
|
||||||
|
- [Acknowledgements](#acknowledgements)
|
||||||
|
- [License](#license)
|
||||||
|
|
||||||
### Features
|
### Features
|
||||||
|
|
||||||
|
|
@ -425,7 +430,7 @@ pub struct MyErrorType {
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
##### ... help text
|
#### ... help text
|
||||||
`miette` provides two facilities for supplying help text for your errors:
|
`miette` provides two facilities for supplying help text for your errors:
|
||||||
|
|
||||||
The first is the `#[help()]` format attribute that applies to structs or
|
The first is the `#[help()]` format attribute that applies to structs or
|
||||||
|
|
@ -461,6 +466,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
|
#### ... multiple related errors
|
||||||
|
|
||||||
`miette` supports collecting multiple errors into a single diagnostic, and
|
`miette` supports collecting multiple errors into a single diagnostic, and
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue