Skip to content

Commit

Permalink
provide the member/property data when returning an invalid error
Browse files Browse the repository at this point in the history
  • Loading branch information
dmathieu committed Feb 4, 2022
1 parent e4c535f commit b3d6bb7
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions baggage/baggage.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,14 +126,14 @@ func parseProperty(property string) (Property, error) {
// validate ensures p conforms to the W3C Baggage specification, returning an
// error otherwise.
func (p Property) validate() error {
if !p.hasData {
return errInvalidProperty
}

errFunc := func(err error) error {
return fmt.Errorf("invalid property: %w", err)
}

if !p.hasData {
return errFunc(fmt.Errorf("%w: %q", errInvalidProperty, p))
}

if !keyRe.MatchString(p.key) {
return errFunc(fmt.Errorf("%w: %q", errInvalidKey, p.key))
}
Expand Down Expand Up @@ -326,7 +326,7 @@ func parseMember(member string) (Member, error) {
// error otherwise.
func (m Member) validate() error {
if !m.hasData {
return errInvalidMember
return fmt.Errorf("%w: %q", errInvalidMember, m)
}

if !keyRe.MatchString(m.key) {
Expand Down

0 comments on commit b3d6bb7

Please sign in to comment.