1
0
mirror of https://github.com/MontFerret/ferret.git synced 2025-06-27 00:41:09 +02:00

Added errors to ClickX methods and added existence check (#341)

* Added errors to ClickX methods and added existence check

* Fixes

* Return None from Iterator when an error occurs
This commit is contained in:
Tim Voronov
2019-07-26 13:22:06 -04:00
committed by GitHub
parent 7e6b3bf15d
commit b323a984cc
10 changed files with 78 additions and 62 deletions

View File

@ -92,11 +92,17 @@ func (i *PagingIterator) Next(ctx context.Context) (core.Value, core.Value, erro
return values.ZeroInt, values.ZeroInt, nil
}
if !i.document.ExistsBySelector(ctx, i.selector) {
return values.ZeroInt, values.ZeroInt, core.ErrNoMoreData
exists, err := i.document.ExistsBySelector(ctx, i.selector)
if err != nil {
return values.None, values.None, err
}
_, err := i.document.ClickBySelector(ctx, i.selector)
if !exists {
return values.None, values.None, core.ErrNoMoreData
}
err = i.document.ClickBySelector(ctx, i.selector)
if err != nil {
return values.None, values.None, err