Capturing errors and problems
An automated task's main characteristic is its fire-and-forget quality. We are not actively looking at the result, but making it run in the background.
Most of the recipes in this book deal with external information, such as web pages or other reports, so the likelihood of finding an unexpected problem when running it is high. This recipe will present an automated task that will safely store unexpected behaviors in a log file that can be checked afterward.
Getting ready
As a starting point, we'll use a task that will divide two numbers, as described in the command line.
This task is very similar to the one presented in step 5 of How it works for the Preparing a task recipe, earlier this chapter. However, instead of multiplying two numbers, we'll divide them.
How to do it...
- Create the
task_with_error_handling_step1.py
file, as follows:import argparse import sys def main(number, other_number...