adverr/error_tmpl_test.go

29 lines
553 B
Go
Raw Normal View History

2020-09-09 11:48:46 +02:00
package adverr
import (
"testing"
)
var (
ErrDoStuffFailed = NewErrTmpl("ErrDoStuffFailed", "test error: %s")
)
func TestErrTmpl(t *testing.T) {
err := doTemplateStuff()
2021-09-09 16:35:48 +02:00
Println(err)
2020-09-09 11:48:46 +02:00
}
func doTemplateStuff() error {
return ErrDoStuffFailed.New("because of reasons")
}
2021-09-09 16:35:48 +02:00
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))
}