Package labelerr provides to add label to error.
go get github.com/nametake/labelerr
package main
import (
"fmt"
"github.com/nametake/labelerr"
"github.com/pkg/errors"
)
func main() {
err := errors.New("cause")
err = errors.Wrap(err, "first")
err = labelerr.Wrap(err, "warning")
err = errors.Wrap(err, "second")
err = errors.Wrap(err, "third")
fmt.Println(err) // third: second: warning: first: cause
fmt.Println(labelerr.Label(err)) // warning
fmt.Println(errors.Cause(err)) // cause
}