Distinguish "The current node list is empty" InvalidArgumentException

Created on 10 February 2025, 14 days ago

Problem/Motivation

In our case we have 1,000 URLs and for a subset of these there is no value present in the markup. What we then get is an InvalidArgumentException with "The current node list is empty" error for every odd URL of the list.

See the Crawler class:

...
    public function link(string $method = 'get'): Link
    {
        if (!$this->nodes) {
            throw new \InvalidArgumentException('The current node list is empty.');
        }

Steps to reproduce

Have a migrate setup with large sets of URLs, having a few odd rows w/o a value for a XPath selector. The migration will fail on the first error and halt.

Proposed resolution

I see we're using the same InvalidArgumentException class as used within Crawler class, but perhaps we could create a different class to distinguish amongst those?
Then we can still halt the migration on faulty usage of the migrate source plugin but are able to catch the Crawler error and emit a warning for the failing URLs.

Remaining tasks

1. Create a different Exception class for supported filter types within the migrate source plugin
2. Catch and log the Crawler's "The current node list is empty" error but continue migration process
3. Review and test change

User interface changes

N/A

API changes

N/A

Data model changes

N/A

🐛 Bug report
Status

Active

Version

1.0

Component

Code

Created by

🇧🇪Belgium baikho Antwerp, BE

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024