47 lines
985 B
Markdown
47 lines
985 B
Markdown
# Playground - Exn
|
|
|
|
Context aware errors.
|
|
|
|
Trying to get exn into structured output for tracing_subscriber.
|
|
|
|
https://github.com/fast/exn
|
|
|
|
https://fast.github.io/blog/stop-forwarding-errors-start-designing-them/
|
|
|
|
example default output:
|
|
|
|
```
|
|
the program died, at src/main.rs:35:34
|
|
|
|
|
|-> failed to create file: res/foo.txt, at src/main.rs:79:43
|
|
|
|
|
|-> Permission denied (os error 13), at src/main.rs:79:43
|
|
```
|
|
|
|
example structured output
|
|
|
|
```json
|
|
{
|
|
"fields": {
|
|
"error": {
|
|
"causes": [
|
|
{
|
|
"causes": [
|
|
{
|
|
"location": "src/main.rs:86:43",
|
|
"message": "Permission denied (os error 13)"
|
|
}
|
|
],
|
|
"location": "src/main.rs:86:43",
|
|
"message": "failed to create file: res/foo.txt"
|
|
}
|
|
],
|
|
"location": "src/main.rs:41:34",
|
|
"message": "the program died"
|
|
}
|
|
},
|
|
"level": "ERROR",
|
|
"target": "playground_exn",
|
|
"timestamp": "2026-03-22T01:19:11.256874822+00:00"
|
|
}```
|