simplify error handling
This commit is contained in:
@@ -196,7 +196,6 @@ def main():
|
|||||||
print("No saint's day today (or today is a holiday/feast day).")
|
print("No saint's day today (or today is a holiday/feast day).")
|
||||||
return
|
return
|
||||||
|
|
||||||
post_errors = []
|
|
||||||
|
|
||||||
for saint in saints:
|
for saint in saints:
|
||||||
print(f"Saint: {saint['name']}")
|
print(f"Saint: {saint['name']}")
|
||||||
@@ -219,14 +218,9 @@ def main():
|
|||||||
print(f" Posted! URL: {status['url']}")
|
print(f" Posted! URL: {status['url']}")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f" Error posting: {e}")
|
print(f" Error posting: {e}")
|
||||||
post_errors.append(str(e))
|
raise
|
||||||
|
|
||||||
print()
|
print()
|
||||||
|
|
||||||
if post_errors:
|
|
||||||
print(f"{len(post_errors)} post(s) failed", file=sys.stderr)
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
|||||||
Reference in New Issue
Block a user