Error decorator that returns native error type in Go
Go to file
Reinaldy Rafli 76eb472c91
feat: init
2021-10-27 21:59:57 +07:00
.github feat: init 2021-10-27 21:59:57 +07:00
.gitignore feat: init 2021-10-27 21:59:57 +07:00
LICENSE feat: init 2021-10-27 21:59:57 +07:00
README.md feat: init 2021-10-27 21:59:57 +07:00
decrr.go feat: init 2021-10-27 21:59:57 +07:00
decrr_test.go feat: init 2021-10-27 21:59:57 +07:00
go.mod feat: init 2021-10-27 21:59:57 +07:00

README.md

Decrr

Go Reference Go Report Card GitHub CodeFactor codecov Codacy Badge Test

A modification (and a bit of simplification) of the 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.

package main

import "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