From df3481d67f83782c7f29071f5b5e0e83f3435885 Mon Sep 17 00:00:00 2001 From: Joshua Sjoding Date: Mon, 15 Feb 2016 19:37:00 -0800 Subject: ObjectLookupIter.Next() now returns ObjectNotFoundErr when appropriate --- core/object.go | 12 +++++++++--- 1 file 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 -- cgit