From 745d4874e624705d5c10ba86b0631fec7807e68f Mon Sep 17 00:00:00 2001 From: Andrew Dunham Date: Wed, 15 Apr 2015 10:58:37 -0700 Subject: [PATCH] Fix Err fallout for graph/iterator.LinksTo iterator --- graph/iterator/linksto_iterator.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/graph/iterator/linksto_iterator.go b/graph/iterator/linksto_iterator.go index 0b2f9c4..005fc37 100644 --- a/graph/iterator/linksto_iterator.go +++ b/graph/iterator/linksto_iterator.go @@ -45,6 +45,7 @@ type LinksTo struct { dir quad.Direction nextIt graph.Iterator result graph.Value + err error runstats graph.IteratorStats } @@ -164,8 +165,17 @@ func (it *LinksTo) Next() bool { return graph.NextLogOut(it, it.nextIt, true) } + // If there's an error in the 'next' iterator, we save it and we're done. + if err := graph.Err(it.nextIt); err != nil { + it.err = err + return false + } + // Subiterator is empty, get another one if !graph.Next(it.primaryIt) { + // Possibly save error + it.err = it.primaryIt.Err() + // We're out of nodes in our subiterator, so we're done as well. return graph.NextLogOut(it, 0, false) } @@ -176,6 +186,10 @@ func (it *LinksTo) Next() bool { return it.Next() } +func (it *LinksTo) Err() error { + return it.err +} + func (it *LinksTo) Result() graph.Value { return it.result }