Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/reconquest/karma-go
Everything has a reason.
https://github.com/reconquest/karma-go
context err errors golang logging tags
Last synced: 3 months ago
JSON representation
Everything has a reason.
- Host: GitHub
- URL: https://github.com/reconquest/karma-go
- Owner: reconquest
- License: mit
- Created: 2017-09-14T20:09:48.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2024-08-08T10:47:41.000Z (6 months ago)
- Last Synced: 2024-08-08T12:56:07.627Z (6 months ago)
- Topics: context, err, errors, golang, logging, tags
- Language: Go
- Homepage:
- Size: 46.9 KB
- Stars: 16
- Watchers: 6
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Contexts
karma has contexts support, which allows to add arbitrary key-value fields
to the error to ease debug.Simplest usage is to add key-values for existing error:
```go
func bar(arg string) error {
return fmt.Errorf("arg is invalid: %s", arg)
}func foo(arg string) error {
err := bar(arg)
if err != nil {
return karma.Describe("method", "bar").Reason(err)
}
}fmt.Println(foo("hello"))
// Output:
//
// arg is invalid: hello
// └─ method: bar
```# Comparison
| Feature | [karma][1] | [errors][2] | [emperror][3] |
| -- | -- | -- | -- |
| Nested Errors | ✔ | ✔ | ✔ |
| Key-Value Context | ✔ | | ~ |
| Descriptive Pretty Print | ✔ | | |
| Embedded Stack Trace | | ✔ | ✔ |
| JSON Friendly | ✔ | | |
| Multi-error Support | ✔ | | ~ |
| Fluid Interface | ✔ | | |# License
This project is licensed under the terms of the MIT license.
[1]: https://github.com/reconquest/karma-go
[2]: https://godoc.org/github.com/pkg/errors
[3]: https://github.com/goph/emperror