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:
@ -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
|
||||
|
Reference in New Issue
Block a user