예제 #1
0
func TestMask(t *testing.T) {
	err0 := errors.WithCausef(nil, someErr, "foo") //err TestMask#0
	err := errors.Mask(err0)                       //err TestMask#1
	checkErr(t, err, err0, "foo", "[{$TestMask#1$: } {$TestMask#0$: foo}]", err)

	err = errors.Mask(nil)
	if err != nil {
		t.Fatalf("expected nil got %#v", err)
	}
}
예제 #2
0
func TestDetails(t *testing.T) {
	if details := errors.Details(nil); details != "[]" {
		t.Fatalf("errors.Details(nil) got %q want %q", details, "[]")
	}

	otherErr := fmt.Errorf("other")
	checkErr(t, otherErr, nil, "other", "[{other}]", otherErr)

	err0 := &embed{errors.New("foo").(*errors.Err)} //err TestStack#0
	checkErr(t, err0, nil, "foo", "[{$TestStack#0$: foo}]", err0)

	err1 := &embed{errors.Notef(err0, "bar").(*errors.Err)} //err TestStack#1
	checkErr(t, err1, err0, "bar: foo", "[{$TestStack#1$: bar} {$TestStack#0$: foo}]", err1)

	err2 := errors.Mask(err1) //err TestStack#2
	checkErr(t, err2, err1, "bar: foo", "[{$TestStack#2$: } {$TestStack#1$: bar} {$TestStack#0$: foo}]", err2)
}