aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoshua Sjoding <joshua.sjoding@scjalliance.com>2016-02-15 19:37:00 -0800
committerJoshua Sjoding <joshua.sjoding@scjalliance.com>2016-02-15 19:37:00 -0800
commitdf3481d67f83782c7f29071f5b5e0e83f3435885 (patch)
tree641bf5f521c04407444b511fc55c02a637091587
parent16f4d888dcec24c2242d5b43673d9a4caed19ae4 (diff)
downloadgo-git-df3481d67f83782c7f29071f5b5e0e83f3435885.tar.gz
ObjectLookupIter.Next() now returns ObjectNotFoundErr when appropriate
-rw-r--r--core/object.go12
1 files changed, 9 insertions, 3 deletions
diff --git a/core/object.go b/core/object.go
index 9b6e56d..2953461 100644
--- a/core/object.go
+++ b/core/object.go
@@ -2,9 +2,14 @@ package core
import (
"bytes"
+ "errors"
"io"
)
+var (
+ ObjectNotFoundErr = errors.New("object not found")
+)
+
// Object is a generic representation of any git object
type Object interface {
Type() ObjectType
@@ -82,8 +87,9 @@ func NewObjectLookupIter(storage ObjectStorage, series []Hash) *ObjectLookupIter
}
// Next returns the next object from the iterator. If the iterator has reached
-// the end it will return io.EOF as an error. If the object is retreieved
-// successfully error will be nil.
+// the end it will return io.EOF as an error. If the object can't be found in
+// the object storage, it will return ObjectNotFoundErr as an error. If the
+// object is retreieved successfully error will be nil.
func (iter *ObjectLookupIter) Next() (Object, error) {
if iter.pos >= len(iter.series) {
return nil, io.EOF
@@ -93,7 +99,7 @@ func (iter *ObjectLookupIter) Next() (Object, error) {
if !ok {
// FIXME: Consider making ObjectStorage.Get return an actual error that we
// could pass back here.
- return nil, io.EOF
+ return nil, ObjectNotFoundErr
}
iter.pos++
return obj, nil