Skip to content

Commit

Permalink
Fix argument type in New
Browse files Browse the repository at this point in the history
  • Loading branch information
m-mizutani committed Nov 6, 2022
1 parent 2caa5eb commit 990c887
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 2 additions & 2 deletions errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import (
)

// New creates a new error with message
func New(format string, args ...string) *Error {
func New(format string, args ...any) *Error {
err := newError()
err.msg = fmt.Sprintf(format, args)
err.msg = fmt.Sprintf(format, args...)
return err
}

Expand Down
5 changes: 5 additions & 0 deletions test/errors_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,8 @@ func TestUnwrap(t *testing.T) {
values := err.Values()
assert.Equal(t, "five", values["color"])
}

func TestFormat(t *testing.T) {
err := goerr.New("test: %s", "blue")
assert.Equal(t, "test: blue", err.Error())
}

0 comments on commit 990c887

Please sign in to comment.