func TestNotef(t *testing.T) { err0 := errors.WithCausef(nil, someErr, "foo") //err TestNotef#0 err := errors.Notef(err0, "bar") //err TestNotef#1 checkErr(t, err, err0, "bar: foo", "[{$TestNotef#1$: bar} {$TestNotef#0$: foo}]", err) err = errors.Notef(nil, "bar") //err TestNotef#2 checkErr(t, err, nil, "bar", "[{$TestNotef#2$: bar}]", err) }
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) }