Description
If an error occurs in any of the actions or the cube is exited along the red line, then the project execution will go to the block that is tied to the Bad End action. This is necessary in order to be able to set some additional actions in case of template termination with an error.
How do I add an action to a project?
Through the context menu Add Action → Logic → BadEnd
Or use smart search .
What is it used for?
When the template is running, unexpected errors may occur, for example:
If the layout on the site has changed and the template now cannot find the required HTML element
Not completely thought out logic of the template, which does not provide for certain situations
Because of this, the project will not be completed to the end and will immediately complete its work. To avoid such situations, you can use Bad End to:
Returning data back to lists / tables for subsequent use without loss.
Logging errors
Adding invalid information to the Blacklist
Saving a backup
How to work with an action?
If the template ends with an error, the actions associated with Bad End will be performed:
Also, Bad End will be triggered when the template is interrupted or when the global execution timeout expires. The setting in ZennoPoster - " Run BadEnd when interrupting the project " is responsible for this:
Bad End fires 1 time for each thread.
Usage example
Data recovery in case of error
For example, to work, we take a deleted string from the list. If in the process of work the template completed with any error, before we processed this line, then this data will be lost. To prevent this from happening, we use Bad End and add to it the action of adding a line to the back list. This way, if the operation fails, the raw data will be saved back to the list for later processing.
How can I track and fix the error?
Each step in the template has a unique identifier, by which it can be found in ProjectMaker. In order to get the id of a step with an error, in ZennoPoster logs, right-click by mistake and press " copy action id ":
Next, in ProjectMaker, call the search (Ctrl + F), insert the received ID and click the "Find" button. The program will highlight the problematic action with a blue border:
Or use the option "Show erroneous action in PM", which will immediately open the project in ProjectMaker with the highlighted action that caused an error during execution:
But all errors are difficult to keep track of, so we recommend logging them to a file. To create a log file that will record an error during project execution, after Bad End, add a Write to file cube and insert the following text into it:
{-TimeNow.Date-} {-Project.LastExecutedActionId-}
Now, when an error occurs in the template, Bad End will create a log.txt file, which will record the time and ID of the error. If the identifier alone is not enough to fix the problem, you can add saving a screenshot of the instance , page source code and variable values . This will allow the most detailed restoration of the picture that led to the error, and make the necessary edits to normalize the project.
Adding invalid information to the Blacklist
You can create a list to store invalid information that leads to errors. For example, an incorrect username / password for an account. During the subsequent work of the template, check for the presence of data in the Blacklist and, if it matches, replace it.
Saving a backup
Save your work profile so that you don't lose it in the event of an error. And after fixing the problem, download it and continue working.