Skip to content

Commit

Permalink
store msg in c.Message instead of c.data[MessagKey]
Browse files Browse the repository at this point in the history
store msg in c.Message instead of c.data[MessagKey]
  • Loading branch information
gertd committed Jul 30, 2024
1 parent 975c0f7 commit e65200c
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,10 @@ func (e *AsertoError) Msg(message string) *AsertoError {
c := e.Copy()

if message != "" {
if existingMsg, ok := c.data[MessageKey]; ok {
c.data[MessageKey] = existingMsg + colon + message
if c.Message != "" {
c.Message = c.Message + colon + message
} else {
c.data[MessageKey] = message
c.Message = message
}
}

Expand All @@ -151,11 +151,14 @@ func (e *AsertoError) Msgf(message string, args ...interface{}) *AsertoError {

message = fmt.Sprintf(message, args...)

if existingMsg, ok := c.data[MessageKey]; ok {
c.data[MessageKey] = existingMsg + colon + message
} else {
c.data[MessageKey] = message
if message != "" {
if c.Message != "" {
c.Message = c.Message + colon + message
} else {
c.Message = message
}
}

return c
}

Expand Down

0 comments on commit e65200c

Please sign in to comment.