Error Handling Alternatives

You can select several alternative methods to handle errors. See Conditions and Error Handling for an error handling overview.

Suppose that some part of a web page has varying structure and layout, but always comes down to one of three cases. In each case there is information to extract. It can be done by attempting the extraction one case at a time. If it fails, the next case is tried, until the third one, which we assume will succeed.


Error handling alternatives

Note the (Try Next Alternative) icons on the Extract steps. If extraction fails, the next branch from the Try step is executed (if a branch coming out of a Try step succeeds, the next branch is not executed). The Extract steps do two things at the same time: They do extraction from the web page, and if it cannot be done, they ensure that the next approach is tried. Note that if either of the two steps on the first branch fails, the second branch is executed; this is an example of how the "success condition" for a branch can be expressed by a combination of steps.

This approach works best if the "third way" of extracting is bound to work (for example, by applying a fixed set of default values rather than actually extracting data from the web page). If the third branch accesses the web page as the first two branches do, it may not be wise to assume that it will succeed. The next time the robot is run, the website may have changed so much that none of the three strategies succeeds, and the robot should be able to respond in a reasonable manner.

The easiest way to respond is to report the problem back to the caller and log it, giving up on doing the extraction and whatever would follow. This can be achieved by making the third branch inform the Try step if it fails to do its work, similar to the first two branches.


Error handling alternatives

(For a Try step, Skip Following Steps means that no additional action is taken beyond reporting and logging.)

Alternatively, it is possible to make the Try step propagate the problem back to an earlier Try step for handling. For more information, see Try-Catch.