Add a try-except block around the git.Repo calls.