https://github.com/gabivlj/error-tree
Format your errors as error trees with stack traces. (Proof of concept dirty code)
https://github.com/gabivlj/error-tree
errors go golang library stack stacktrace stacktraces trace xerrors
Last synced: 6 months ago
JSON representation
Format your errors as error trees with stack traces. (Proof of concept dirty code)
- Host: GitHub
- URL: https://github.com/gabivlj/error-tree
- Owner: gabivlj
- License: mit
- Created: 2023-02-21T01:41:06.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2023-02-21T01:55:40.000Z (almost 3 years ago)
- Last Synced: 2025-06-11T03:37:01.075Z (7 months ago)
- Topics: errors, go, golang, library, stack, stacktrace, stacktraces, trace, xerrors
- Language: Go
- Homepage:
- Size: 4.88 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Rrors
A proof-of-concept Golang error library that renders your error stack trace as a tree. Similar to xerrors but with support to `errors.Join`.
See the tests folder to see sample renderings.
# Is this ready?
This is a proof of concept and hacky code all around, I'm just testing the idea :)
# Usage
This is at your own risk, code is not perfect, but the idea is wrapping errors and preserving the stacktrace like `xerrors` did, but also
adaption to errors.Join from go 1.20
```golang
err := rrors.Errorf("some error: %w", errors.Join(...))
// prints tree with stacktrace
fmt.Println(err)
```
## Untested things
- rrors.Errorf("%w %w") ?
- errors.Is(rrors.Errorf(...)) ?
- errors.As(...)
## Plans
Add ways to query an error tree like doing:
- `rerrs.CountErrors(err, os.ErrNotFound)` // counts the number of ErrNotFound in the error tree
- `rerrs.AsMultiple[MyErrorType](err)` // returns errors of this type in the error tree