diff --git a/get_saint_of_the_day.py b/get_saint_of_the_day.py index a08b4b4..24be33d 100644 --- a/get_saint_of_the_day.py +++ b/get_saint_of_the_day.py @@ -7,6 +7,7 @@ Optionally posts to Mastodon with the --post flag. import argparse import csv import os +import sys from datetime import datetime from pathlib import Path import urllib.parse @@ -195,6 +196,8 @@ def main(): print("No saint's day today (or today is a holiday/feast day).") return + post_errors = [] + for saint in saints: print(f"Saint: {saint['name']}") print(f"French: {saint['french_name']}") @@ -216,9 +219,14 @@ def main(): print(f" Posted! URL: {status['url']}") except Exception as e: print(f" Error posting: {e}") + post_errors.append(str(e)) print() + if post_errors: + print(f"{len(post_errors)} post(s) failed", file=sys.stderr) + sys.exit(1) + if __name__ == "__main__": main()