https://github.com/aldy505/decrr
Error decorator that returns native error type in Go
https://github.com/aldy505/decrr
error-handling error-wrapper go golang
Last synced: 6 days ago
JSON representation
Error decorator that returns native error type in Go
- Host: GitHub
- URL: https://github.com/aldy505/decrr
- Owner: aldy505
- License: mit
- Created: 2021-10-27T15:00:03.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2024-02-11T12:55:27.000Z (over 1 year ago)
- Last Synced: 2025-02-26T12:42:57.174Z (3 months ago)
- Topics: error-handling, error-wrapper, go, golang
- Language: Go
- Homepage:
- Size: 10.7 KB
- Stars: 6
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# Decrr
[](https://pkg.go.dev/github.com/aldy505/decrr) [](https://goreportcard.com/report/github.com/aldy505/decrr)  [](https://www.codefactor.io/repository/github/aldy505/decrr) [](https://codecov.io/gh/aldy505/decrr) [](https://www.codacy.com/gh/aldy505/decrr/dashboard?utm_source=github.com&utm_medium=referral&utm_content=aldy505/decrr&utm_campaign=Badge_Grade) [](https://github.com/aldy505/decrr/actions/workflows/ci.yml)
A modification (and a bit of simplification) of the [tracerr](https://github.com/ztrue/tracerr) package.
This essentially does pretty much the same, but instead of returning another struct like tracerr package does, this decorate the error and return another regular error type.
## Usage
Simply put it on the deepest function/method on your project.
```go
package mainimport "github.com/aldy505/decrr"
func main() {
err := ExecuteSomething()
log.Fatal(err)
}func ExecuteSomething() error {
return SomethingElse()
}func SomethingElse() error {
err := errors.New("a goat just passes by!")
return decrr.Wrap(err)
}
```And yes, it only has one `.Wrap(error)` function. Nothing else.
## License
[MIT License](./LICENSE)