libgit2/git2go — pull request #40 by carlosmn (2013-09-15 16:22:46+00:00)
Title: Named errors

As #35 points out, the usage of `LastError()` as a return value can hide some of the information in the return value. A programmer might want to distinguish between "not found" and "invalid" in rev-parse, for example.

This goes off in a different direction and hopes to provides something that's somwehat idiomatic. Special return codes like `ENOTFOUND` or `ITEROVER` are named (similar to what the standard library does) so you can compare with a pointer equality.

For `-1` there is no information lost by returning `LastError()`, so we can return just that. `makeError()` handles the no-error case in order to simplify the code you have to write at the call site, when you're simply proxying values into libgit2.