Each step should have a binary status. These should combine to form a status bit group, which will be represented as a decimal number.
e.g., 11111111 would represent the status of eight steps, thus 255.
After each step a bitwise AND operation will be applied to clear the stage-specific bit, by using a mask representing that stage.
e.g., LSB may refer to reading the map file. Once done, apply AND between current status and 11111110. This yields a decimal error 254.
Similarly each stage will change their respective status to 0, thereby reducing the error status, until it reaches 0, indicating successful script completion.
For stages that are NA, they will simply change their status to 0, thus implying stage success.
The following tasks are proposed
Identify bit depth based on the number of checked stages of the script
Arrange bits to formulate a binary error status
Convert each error status to decimal to create an error map (for documentation)
Create a mask for each stage to use in the AND operation to clear the error state for that stage