do {} fail(error) {} success{} finally{}


Four named code blocks that provide a way to handle errors before they can become a problem.


This code block will be executed for as far as no error occurs. Execution then continues to the next relevant of three (optional) blocks, even when a return statetement has been reached. This is the only block that may contain a return statement.


Will be executed right after an error occurred in the do block. Can have the error message as parameter. Execution continues to finally block if it exists.


Will be executed after the do block ran without error. Continues to finally block if it exists.


Will always be executed last.


When a robot is busy scraping web pages and downloading content, it will sometimes stumble upon invalid links, which can give runtime errors. As an example, an error like that will be caught here.

use System, Web;

var imageUrl = "";
do {
	// Induce an error
	var test =, "D:/temp/testimage.jpg");
} fail(error) {
	// Catch it
	System.print("The following error has occurred on line " :: error.line :: ": " :: error.message);
} success {
	System.print("Successfully executed the do-block");
} finally {
	// this will always be run last
	System.print("This is the finally block.");

will print:

The following error has occurred on line 6: Error during download
This is the finally block.


Inside a do block it is allowed to use the same blocks as described above.