diff options
| author | Carlos Martín Nieto <[email protected]> | 2013-05-21 11:51:31 +0200 |
|---|---|---|
| committer | Carlos Martín Nieto <[email protected]> | 2013-05-21 11:51:31 +0200 |
| commit | d824ea415d050f5b41ce7eb680b137de653c843e (patch) | |
| tree | 1459240f90655713ac630886bafd3b04a9a6a9de | |
| parent | 4e0a28b064047513194a842e9c16d9beab545f41 (diff) | |
Catch nil error instances
Unfortunately libgit2 sometimes returns an error without setting an
error message. Provide an alternative message instead of trying to
dereference nil.
| -rw-r--r-- | git.go | 4 |
1 files changed, 4 insertions, 0 deletions
@@ -10,6 +10,7 @@ import ( "bytes" "unsafe" "strings" + "fmt" ) const ( @@ -107,6 +108,9 @@ func (e GitError) Error() string{ func LastError() error { err := C.giterr_last() + if err == nil { + return &GitError{"No message", 0} + } return &GitError{C.GoString(err.message), int(err.klass)} } |
