mirror of
https://github.com/haraldh/chainerror.git
synced 2025-01-31 00:56:41 +01:00
doc: extend README.md with display formats
Signed-off-by: Harald Hoyer <harald@hoyer.xyz>
This commit is contained in:
parent
46b7f58e72
commit
9e03541ac1
75
README.md
75
README.md
|
@ -90,6 +90,81 @@ Along with the `Error<T>` struct, `chainerror` comes with some useful helper mac
|
||||||
|
|
||||||
Debug information is worth it!
|
Debug information is worth it!
|
||||||
|
|
||||||
|
## Multiple Output Formats
|
||||||
|
|
||||||
|
`chainerror` supports multiple output formats, which can be selected with the different format specifiers:
|
||||||
|
|
||||||
|
* `{}`: Display
|
||||||
|
```text
|
||||||
|
func1 error calling func2
|
||||||
|
```
|
||||||
|
|
||||||
|
* `{:#}`: Alternative Display
|
||||||
|
```text
|
||||||
|
func1 error calling func2
|
||||||
|
Caused by:
|
||||||
|
func2 error: calling func3
|
||||||
|
Caused by:
|
||||||
|
(passed error)
|
||||||
|
Caused by:
|
||||||
|
Error reading 'foo.txt'
|
||||||
|
Caused by:
|
||||||
|
entity not found
|
||||||
|
```
|
||||||
|
|
||||||
|
* `{:?}`: Debug
|
||||||
|
```text
|
||||||
|
examples/example.rs:50:13: func1 error calling func2
|
||||||
|
Caused by:
|
||||||
|
examples/example.rs:25:13: Func2Error(func2 error: calling func3)
|
||||||
|
Caused by:
|
||||||
|
examples/example.rs:18:13: (passed error)
|
||||||
|
Caused by:
|
||||||
|
examples/example.rs:13:18: Error reading 'foo.txt'
|
||||||
|
Caused by:
|
||||||
|
Kind(NotFound)
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
* `{:#?}`: Alternative Debug
|
||||||
|
```text
|
||||||
|
Error<example::Func1Error> {
|
||||||
|
occurrence: Some(
|
||||||
|
"examples/example.rs:50:13",
|
||||||
|
),
|
||||||
|
kind: func1 error calling func2,
|
||||||
|
source: Some(
|
||||||
|
Error<example::Func2Error> {
|
||||||
|
occurrence: Some(
|
||||||
|
"examples/example.rs:25:13",
|
||||||
|
),
|
||||||
|
kind: Func2Error(func2 error: calling func3),
|
||||||
|
source: Some(
|
||||||
|
Error<chainerror::AnnotatedError> {
|
||||||
|
occurrence: Some(
|
||||||
|
"examples/example.rs:18:13",
|
||||||
|
),
|
||||||
|
kind: (passed error),
|
||||||
|
source: Some(
|
||||||
|
Error<alloc::string::String> {
|
||||||
|
occurrence: Some(
|
||||||
|
"examples/example.rs:13:18",
|
||||||
|
),
|
||||||
|
kind: "Error reading 'foo.txt'",
|
||||||
|
source: Some(
|
||||||
|
Kind(
|
||||||
|
NotFound,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
},
|
||||||
|
),
|
||||||
|
},
|
||||||
|
),
|
||||||
|
},
|
||||||
|
),
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
## Tutorial
|
## Tutorial
|
||||||
|
|
||||||
Read the [Tutorial](https://haraldh.github.io/chainerror/tutorial1.html)
|
Read the [Tutorial](https://haraldh.github.io/chainerror/tutorial1.html)
|
||||||
|
|
Loading…
Reference in a new issue