Skip to content

Commit

Permalink
improve codec error strings
Browse files Browse the repository at this point in the history
  • Loading branch information
coder543 committed May 10, 2019
1 parent 2593f3d commit 21c27ff
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,15 +114,15 @@ func (u *UUID) UnmarshalText(text []byte) error {
case 41, 45:
return u.decodeURN(text)
default:
return fmt.Errorf("uuid: incorrect UUID length: %s", text)
return fmt.Errorf("uuid: incorrect UUID length %d in string %q", len(text), text)
}
}

// decodeCanonical decodes UUID strings that are formatted as defined in RFC-4122 (section 3):
// "6ba7b810-9dad-11d1-80b4-00c04fd430c8".
func (u *UUID) decodeCanonical(t []byte) error {
if t[8] != '-' || t[13] != '-' || t[18] != '-' || t[23] != '-' {
return fmt.Errorf("uuid: incorrect UUID format %s", t)
return fmt.Errorf("uuid: incorrect UUID format in string %q", t)
}

src := t
Expand Down Expand Up @@ -160,7 +160,7 @@ func (u *UUID) decodeBraced(t []byte) error {
l := len(t)

if t[0] != '{' || t[l-1] != '}' {
return fmt.Errorf("uuid: incorrect UUID format %s", t)
return fmt.Errorf("uuid: incorrect UUID format in string %q", t)
}

return u.decodePlain(t[1 : l-1])
Expand All @@ -175,7 +175,7 @@ func (u *UUID) decodeURN(t []byte) error {
urnUUIDPrefix := t[:9]

if !bytes.Equal(urnUUIDPrefix, urnPrefix) {
return fmt.Errorf("uuid: incorrect UUID format: %s", t)
return fmt.Errorf("uuid: incorrect UUID format in string %q", t)
}

return u.decodePlain(t[9:total])
Expand All @@ -191,7 +191,7 @@ func (u *UUID) decodePlain(t []byte) error {
case 36:
return u.decodeCanonical(t)
default:
return fmt.Errorf("uuid: incorrect UUID length: %s", t)
return fmt.Errorf("uuid: incorrect UUID length %d in string %q", len(t), t)
}
}

Expand Down

0 comments on commit 21c27ff

Please sign in to comment.