adverr/error_tmpl_test.go
2021-09-09 16:35:48 +02:00

29 lines
553 B
Go

package adverr
import (
"testing"
)
var (
ErrDoStuffFailed = NewErrTmpl("ErrDoStuffFailed", "test error: %s")
)
func TestErrTmpl(t *testing.T) {
err := doTemplateStuff()
Println(err)
}
func doTemplateStuff() error {
return ErrDoStuffFailed.New("because of reasons")
}
func TestErrTmplChain(t *testing.T) {
errors := make([]error, 0)
errors = append(errors, doTemplateStuff())
errors = append(errors, doTemplateStuff())
errors = append(errors, doTemplateStuff())
Println(ErrDoStuffFailed.Chain("Neither of that stuff worked", errors))
}