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()
|
||||
except OSError as e:
|
||||
message = '>>> No secret found.'
|
||||
raise Exception(message)
|
||||
print(message)
|
||||
|
||||
# todo, check if access_token exist in secret_file
|
||||
if secret == None:
|
||||
|
@ -49,8 +49,12 @@ def initialize_client(app):
|
|||
|
||||
else:
|
||||
#... otherwise, reuse
|
||||
mastodon = Mastodon(access_token=app['secret_file'])
|
||||
print('>>> Reused persisted token!')
|
||||
try:
|
||||
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:
|
||||
try:
|
||||
|
|
Loading…
Reference in a new issue