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:
parent
30f4d29d5a
commit
48ca6ec3ea
1 changed files with 7 additions and 3 deletions
10
mastodon.py
10
mastodon.py
|
@ -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
|
||||||
mastodon = Mastodon(access_token=app['secret_file'])
|
try:
|
||||||
print('>>> Reused persisted token!')
|
mastodon = Mastodon(access_token=app['secret_file'])
|
||||||
|
print('>>> Reused persisted token!')
|
||||||
|
except:
|
||||||
|
message = '>>> Persisted token did not work'
|
||||||
|
raise Exception(message)
|
||||||
|
|
||||||
if session_id == None:
|
if session_id == None:
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Reference in a new issue