Skip to content

Commit

Permalink
better error message
Browse files Browse the repository at this point in the history
  • Loading branch information
vetinari committed Jun 26, 2017
1 parent 346145e commit 3a68c22
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions dn.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@ func ParseDN(str string) (*DN, error) {
}
} else if char == ',' || char == '+' {
// We're done with this RDN or value, push it
if attribute.Type == "" {
return nil, fmt.Errorf("missing attribute type")
if len(attribute.Type) == 0 {
return nil, errors.New("incomplete type, value pair")
}
attribute.Value = stringFromBuffer()
rdn.Attributes = append(rdn.Attributes, attribute)
Expand Down
2 changes: 1 addition & 1 deletion dn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func TestErrorDNParsing(t *testing.T) {
"cn=Jim\\0": "Got corrupted escaped character",
"DC=example,=net": "DN ended with incomplete type, value pair",
"1=#0402486": "Failed to decode BER encoding: encoding/hex: odd length hex string",
"test,DC=example,DC=com": "missing attribute type",
"test,DC=example,DC=com": "incomplete type, value pair",
}

for test, answer := range testcases {
Expand Down

0 comments on commit 3a68c22

Please sign in to comment.