Version/v2.6.0 beta (#3183)

This commit is contained in:
John Guo
2023-12-04 19:34:48 +08:00
committed by GitHub
parent 0b6dd6fb13
commit ee2cf92479
39 changed files with 128 additions and 90 deletions

View File

@ -16,9 +16,9 @@ type Option struct {
Code gcode.Code // Error code if necessary.
}
// NewOption creates and returns a custom error with Option.
// NewWithOption creates and returns a custom error with Option.
// It is the senior usage for creating error, which is often used internally in framework.
func NewOption(option Option) error {
func NewWithOption(option Option) error {
err := &Error{
error: option.Error,
text: option.Text,
@ -29,3 +29,9 @@ func NewOption(option Option) error {
}
return err
}
// NewOption creates and returns a custom error with Option.
// Deprecated: use NewWithOption instead.
func NewOption(option Option) error {
return NewWithOption(option)
}

View File

@ -442,7 +442,7 @@ func Test_HashCode(t *testing.T) {
func Test_NewOption(t *testing.T) {
gtest.C(t, func(t *gtest.T) {
t.AssertNE(gerror.NewOption(gerror.Option{
t.AssertNE(gerror.NewWithOption(gerror.Option{
Error: errors.New("NewOptionError"),
Stack: true,
Text: "Text",