feat: improve error handling of mastodon operations

- don't raise exception when reading secret file fails
- raise exception when initializing masto client w/ persisted secret fails
This commit is contained in:
Ayo Ayco 2025-01-19 14:51:10 +01:00
parent 30f4d29d5a
commit 48ca6ec3ea

View file

@ -30,7 +30,7 @@ def initialize_client(app):
secret = secret_file.read() secret = secret_file.read()
except OSError as e: except OSError as e:
message = '>>> No secret found.' message = '>>> No secret found.'
raise Exception(message) print(message)
# todo, check if access_token exist in secret_file # todo, check if access_token exist in secret_file
if secret == None: if secret == None:
@ -49,8 +49,12 @@ def initialize_client(app):
else: else:
#... otherwise, reuse #... otherwise, reuse
try:
mastodon = Mastodon(access_token=app['secret_file']) mastodon = Mastodon(access_token=app['secret_file'])
print('>>> Reused persisted token!') print('>>> Reused persisted token!')
except:
message = '>>> Persisted token did not work'
raise Exception(message)
if session_id == None: if session_id == None:
try: try: