Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion context.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func WrapContext(err error, ctx context.Context, message string) *ContextError {
return WithContext(errors.Wrap(err, message), ctx)
}

func WrapfContext(err error, ctx context.Context, format string, args ...interface{}) *ContextError {
func WrapfContext(err error, ctx context.Context, format string, args ...any) *ContextError {
return WithContext(errors.Wrapf(err, format, args...), ctx)
}

Expand Down
16 changes: 12 additions & 4 deletions errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"fmt"
"io"
"maps"
"net/http"
"strconv"
"strings"
Expand Down Expand Up @@ -109,8 +110,15 @@ func (e *AsertoError) Error() string {
return fmt.Sprintf("%s %s: %s", e.Code, e.Message, innerMessage)
}

func (e *AsertoError) Fields() map[string]interface{} {
result := make(map[string]interface{}, len(e.data))
func (e *AsertoError) Fields() map[string]any {
result := make(map[string]any, len(e.data))

for _, err := range e.errs {
var aerr *AsertoError
if ok := errors.As(err, &aerr); ok {
maps.Copy(result, aerr.Fields())
}
}

for k, v := range e.data {
result[k] = v
Expand Down Expand Up @@ -145,7 +153,7 @@ func (e *AsertoError) Msg(message string) *AsertoError {
return c
}

func (e *AsertoError) Msgf(message string, args ...interface{}) *AsertoError {
func (e *AsertoError) Msgf(message string, args ...any) *AsertoError {
c := e.Copy()

message = fmt.Sprintf(message, args...)
Expand Down Expand Up @@ -221,7 +229,7 @@ func (e *AsertoError) FromReader(key string, value io.Reader) *AsertoError {
return c
}

func (e *AsertoError) Interface(key string, value interface{}) *AsertoError {
func (e *AsertoError) Interface(key string, value any) *AsertoError {
c := e.Copy()
c.data[key] = fmt.Sprintf("%+v", value)

Expand Down
Loading