Next / Previous / Contents / Shipman's homepage

3.5. Error recovery

The program detects a large number of different errors from the input file. However, it would be annoying to the operator if the program always terminated on the first error of any kind.

In order to streamline production of new data files, we'll try to report on as many errors as possible per execution of the program. Here is the error recovery strategy.

We will use the .syntax() method of the Scan class to combine the reporting of syntax errors with the raising of SyntaxError exceptions. In this way, each of the methods that reads one of the input files has this overall flow:

  1. Interrogate the Log().count() method initially to find the current number of error messages.

  2. Read through the lines of the file. Catch and ignore any SyntaxError exceptions.

  3. When the file has been exhausted, again interrogate Log().count(), and if the error message count has changed, terminate execution.