diff --git a/errors.go b/errors.go index 1f3bf62..f34c153 100644 --- a/errors.go +++ b/errors.go @@ -133,7 +133,7 @@ func (x *Error) Unwrap() error { } // With adds key and value related to the error event -func (x *Error) With(key string, value any) *Error { +func (x *Error) With(key, value any) *Error { x.values[key] = value return x } diff --git a/test/errors_test.go b/test/errors_test.go index 79cb985..a08eea6 100644 --- a/test/errors_test.go +++ b/test/errors_test.go @@ -113,3 +113,9 @@ func TestLoggingNestedError(t *testing.T) { assert.Contains(t, out.String(), `"number":"five"`) assert.Contains(t, out.String(), `"color":"orange"`) } + +func TestWithAnyKey(t *testing.T) { + type myKey struct{} + err := goerr.New("e1").With(myKey{}, "orange") + assert.Equal(t, "orange", err.Values()[myKey{}]) +}