Skip to content

Commit 0942474

Browse files
author
Vicent Martí
committed
Merge pull request libgit2#25 from carlosmn/error-nil
Catch nil error instances
2 parents 7823b14 + d824ea4 commit 0942474

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

git.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"errors"
1212
"unsafe"
1313
"strings"
14+
"fmt"
1415
)
1516

1617
const (
@@ -132,6 +133,9 @@ func (e GitError) Error() string{
132133

133134
func LastError() error {
134135
err := C.giterr_last()
136+
if err == nil {
137+
return &GitError{"No message", 0}
138+
}
135139
return &GitError{C.GoString(err.message), int(err.klass)}
136140
}
137141

0 commit comments

Comments
 (0)