Skip to content

Commit 37c4950

Browse files
committed
commit: improve error messages
Right now, the error message when trying to parse an invalid tree or parent header is hard to pin down because it's simply a generic hex string parsing error. Make the error easier to discover in the future by adding some descriptive text to indicate to the user what the problem is.
1 parent 5f09182 commit 37c4950

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

commit.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,13 +123,13 @@ func (c *Commit) Decode(hash hash.Hash, from io.Reader, size int64) (n int, err
123123
case "tree":
124124
id, err := hex.DecodeString(fields[1])
125125
if err != nil {
126-
return n, err
126+
return n, fmt.Errorf("error parsing tree: %s", err)
127127
}
128128
c.TreeID = id
129129
case "parent":
130130
id, err := hex.DecodeString(fields[1])
131131
if err != nil {
132-
return n, err
132+
return n, fmt.Errorf("error parsing parent: %s", err)
133133
}
134134
c.ParentIDs = append(c.ParentIDs, id)
135135
case "author":

0 commit comments

Comments
 (0)