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.
Any error on a line of the ranks file will terminate scanning of that line, but we will continue to read and scan the remaining lines.
If there were any errors at all in the ranks file, the program terminates at that point because the processing of the standard forms file requires the rank hierarchy to be completely in place.
Similarly, when any line of the standard forms file has an error, we terminate processing of that line, but then continue reading the remaining lines. When the file is exhausted, if there have been any errors, the program terminates.
Processing of the alternate forms file pursues the same strategy: erroneous lines do not terminate processing of the file, but after reading the entire file, the program will terminate if there have been any errors. will term
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:
Interrogate the Log().count() method
initially to find the current number of error messages.
Read through the lines of the file. Catch and ignore
any SyntaxError exceptions.
When the file has been exhausted, again interrogate Log().count(), and if the error message count has
changed, terminate execution.