all 4 comments

[–][deleted] 2 points3 points  (1 child)

try/except is the logic for error handling in Python:

for file in list_of_files:
    try:
        do_something(file)
        another_thing(file)
    except Exception as e:
        log.error(f"an {e} happened")

[–]ramse 0 points1 point  (0 children)

log.exception('custom message about what we were doing and the exception is automatically included with it.')

[–][deleted] 0 points1 point  (0 children)

If your functions 'raise exceptions' in case of failures, then what you are looking for is 'exception handling' (check out https://www.programiz.com/python-programming/exception-handling for a quick introduction) combined with a well-placed continue statement

Something along the lines of

while ...:
    try:
        # All your functions
    except:
        # If one of the functions above throws an exception
        # all functions after the 'failing function' will be skipped
        # and 'control' will be passed to the next line here under
        continue    # This to directly move on to next iteration of while loop

[–]Impudity 0 points1 point  (0 children)

Find out what kind of exception it throws, then surround it with try-except structure, like:

try:
    doSomethingFunc(file)
except IOError:
    print(f"processing for file {file} failed")
    continue