func TestNewf(t *testing.T) { err := errstack.Newf("my bad %d", 42) if err == nil { t.Fatalf("expected an error. got=%#v\n", err) } if err, ok := err.(*errstack.Error); !ok { t.Fatalf("expected an *errstack.Error. got=%T\n", err) } else { exp := fmt.Errorf("my bad %d", 42) if !reflect.DeepEqual(err.Err, exp) { t.Fatalf("expected err.Err=%v.\ngot=%v\n", exp, err.Err) } } }
// Errorf formats according to a format specifier and returns the string as // a value that satisfies error, together with the associated stack trace. func Errorf(format string, args ...interface{}) error { return errstack.Newf(format, args...) }