Skip to content

Commit

Permalink
Improve error message generation
Browse files Browse the repository at this point in the history
  • Loading branch information
roeldev committed Jan 1, 2021
1 parent dfcc66e commit 3863cf4
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions error.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,18 @@ func (ce *commonErr) GoString() string {
}

func errMsg(msg string, kind Kind, code int) string {
hasKind, hasCode := kind != UnknownKind, code != 0
if !hasKind && !hasCode {
return msg
}

var buf strings.Builder
if kind != UnknownKind {
if hasKind {
buf.WriteString(kind.String())
buf.WriteRune(':')
buf.WriteRune(' ')
}
if code != 0 {
if hasCode {
buf.WriteRune('[')
buf.WriteString(strconv.Itoa(code))
buf.WriteRune(']')
Expand Down

0 comments on commit 3863cf4

Please sign in to comment.