docs: add docs for handler options

This commit is contained in:
Kat Marchán 2021-09-26 12:45:18 -07:00
parent e52996bdf4
commit 47e4d4d05c
No known key found for this signature in database
GPG Key ID: AEB529C08A3C7E9E
2 changed files with 33 additions and 0 deletions

View File

@ -41,6 +41,7 @@ and such might not want.
- [... in `main()`](#-in-main)
- [... diagnostic code URLs](#-diagnostic-code-urls)
- [... snippets](#-snippets)
- [... handler options](#-handler-options)
- [Acknowledgements](#acknowledgements)
- [License](#license)
@ -353,6 +354,26 @@ pub struct MyErrorType {
}
```
### ... handler options
[MietteHandler] is the default handler, and is very customizable. In most
cases, you can simply use [MietteHandlerOptions] to tweak its behavior instead
of falling back to your own custom handler.
Usage is like so:
```rust
miette::set_hook(|_| {
MietteHandlerOpts::new()
.terminal_links(true)
.unicode(false)
.context_lines(3)
.build()
})
```
See the docs for [MietteHandlerOptions] for more details on what you can customize!
## Acknowledgements
`miette` was not developed in a void. It owes enormous credit to various other projects and their authors:

View File

@ -12,6 +12,18 @@ use crate::ThemeStyles;
/**
Create a custom [MietteHandler] from options.
## Example
```no_run
miette::set_hook(|_| {
MietteHandlerOpts::new()
.terminal_links(true)
.unicode(false)
.context_lines(3)
.build()
})
```
*/
#[derive(Default, Debug, Clone)]
pub struct MietteHandlerOpts {