From 77aa0b370669913ae9b6c30db1a67f1e89928bd9 Mon Sep 17 00:00:00 2001 From: Mark Eaton Date: Fri, 20 Feb 2026 17:21:41 -0500 Subject: [PATCH] fix: exit non-zero on Mastodon post failure The script was swallowing exceptions and exiting 0, so systemd considered the service successful and never triggered OnFailure to notify via Gitea. Co-Authored-By: Claude Opus 4.6 --- get_saint_of_the_day.py | 8 ++++++++ 1 file changed, 8 insertions(+) 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()