mirror of
https://gitlab.com/jeancf/twoot.git
synced 2024-11-23 20:11:11 +00:00
Handle 422 errors differently
This commit is contained in:
parent
0bee03dd56
commit
9231a78881
10
twoot.py
10
twoot.py
|
@ -1219,10 +1219,12 @@ def main(argv):
|
|||
toot = mastodon.status_post(tweet['tweet_text'], replied_to_toot, media_ids=media_ids)
|
||||
|
||||
except MastodonAPIError as e:
|
||||
logging.debug('PROBING DETAILS OF MastodonAPIError')
|
||||
logging.debug(e.args)
|
||||
logging.debug(e.__notes__)
|
||||
# Assuming this is an:
|
||||
_, _, _, exception_message = e.args
|
||||
if 'Text character limit' in exception_message:
|
||||
# ERROR (('Mastodon API returned error', 422, 'Unprocessable Entity', 'Validation failed: Text character limit of 500 exceeded'))
|
||||
logging.error('Tweet text too long: %s characters', str(len(tweet['tweet_text'])))
|
||||
shutdown(-1)
|
||||
elif 'Try again in a moment' in exception_message:
|
||||
# ERROR ('Mastodon API returned error', 422, 'Unprocessable Entity', 'Cannot attach files that have not finished processing. Try again in a moment!')
|
||||
logging.warning('Mastodon API Error 422: Cannot attach files that have not finished processing. Waiting 30 seconds and retrying.')
|
||||
# Wait 30 seconds
|
||||
|
|
Loading…
Reference in New Issue
Block a user