Skip to content

Commit

Permalink
Cleanup README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
alnvdl committed Mar 10, 2023
1 parent 5e0b6e2 commit b7999d8
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,20 +52,22 @@ used at one point, the error tracing information will be reset at that point
around `fmt.Errorf`. Any traced error passed to `terr.Newf` will be included in
the traced error tree, regardless of the `fmt` verb used.

This is an example of terr in use:
## Example
The following code:
```go
err := terr.Newf("base")
traced := terr.Trace(err)
wrapped := terr.Newf("wrapped: %w", traced)
masked := terr.Newf("masked: %v", wrapped)
fmt.Printf("%@\n", masked)
```
Which will output:

Will output:
```
masked: wrapped: base @ /home/alnvdl/dev/terr/terr_test.go:194
wrapped: base @ /home/alnvdl/dev/terr/terr_test.go:193
base @ /home/alnvdl/dev/terr/terr_test.go:192
base @ /home/alnvdl/dev/terr/terr_test.go:191
masked: wrapped: base @ /mygomod/file.go:14
wrapped: base @ /mygomod/file.go:13
base @ /mygomod/file.go:12
base @ /mygomod/file.go:11
```

## Printing errors
Expand Down

0 comments on commit b7999d8

Please sign in to comment.