https://github.com/pvormste/yeterr
A package for providing helper functionalities for errors.
https://github.com/pvormste/yeterr
collection errors go golang library package
Last synced: 15 days ago
JSON representation
A package for providing helper functionalities for errors.
- Host: GitHub
- URL: https://github.com/pvormste/yeterr
- Owner: pvormste
- License: mit
- Created: 2020-01-19T08:52:41.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2020-03-29T09:43:57.000Z (about 6 years ago)
- Last Synced: 2025-12-28T12:44:33.600Z (5 months ago)
- Topics: collection, errors, go, golang, library, package
- Language: Go
- Homepage: https://pkg.go.dev/github.com/pvormste/yeterr
- Size: 45.9 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://github.com/pvormste/yeterr/blob/master/LICENSE)   [](https://godoc.org/github.com/pvormste/yeterr)
# yeterr
yeterr is a package which provides helper functionalities for working with errors.
At the current state it only adds a report for collecting errors and filter them.
## Collection
The error report allows to collect errors and adding metadata and flags to them.
```go
const (
flagWarning yeterr.ErrorFlag = "warning"
flagSerious yeterr.ErrorFlag = "serious"
)
func example() {
report := yeterr.NewSimpleReport()
report.AddError(errors.New("not flagged"), nil)
report.AddFlaggedError(errors.New("warning"), yeterr.Metadata{"time", time.Now().String()}, flagWarning)
report.AddFlaggedError(errors.New("serious"), yeterr.Metadata{"time": time.Now().String()}, flagSerious)
report.AddFlaggedFatalError(errors.New("really serious"), nil, flagSerious)
seriousErrors := report.FilterErrorsByFlag(flagSerious) // 2 items
fatalSeriousError := report.FatalError() // returns the "really serious" error
}
```
For more detailed information please visit the pkg docs: https://pkg.go.dev/github.com/pvormste/yeterr