/decrr

Error decorator that returns native error type in Go

Primary LanguageGoMIT LicenseMIT

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