2020-09-09 11:48:46 +02:00
|
|
|
package adverr
|
|
|
|
|
|
|
|
import (
|
|
|
|
"errors"
|
|
|
|
"fmt"
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestErr(t *testing.T) {
|
2020-09-10 15:05:28 +02:00
|
|
|
DisableTrace = false
|
2020-09-09 11:48:46 +02:00
|
|
|
err := doStuff()
|
2021-09-09 16:35:48 +02:00
|
|
|
Println(err)
|
2020-09-09 11:48:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func doStuff() error {
|
|
|
|
return Wrap("wrapped error", Wrap("test error", fmt.Errorf("asd: %w", errors.New("test"))))
|
|
|
|
}
|
2021-09-09 16:35:48 +02:00
|
|
|
|
|
|
|
func TestErrorChain(t *testing.T) {
|
|
|
|
|
|
|
|
errors := make([]error, 0)
|
|
|
|
|
|
|
|
errors = append(errors, doStuff())
|
|
|
|
errors = append(errors, doStuff())
|
|
|
|
errors = append(errors, doStuff())
|
|
|
|
|
|
|
|
Println(Chain("Neither of that stuff worked", errors))
|
|
|
|
}
|