Add log for Mastodon internal server error (500)

This commit is contained in:
jeancf 2023-10-30 13:42:20 +01:00
parent 365467166a
commit 123bf33faf

View File

@ -434,8 +434,12 @@ def main(argv):
toot = mastodon.status_post(tweet['tweet_text'], replied_to_toot, media_ids=media_ids) toot = mastodon.status_post(tweet['tweet_text'], replied_to_toot, media_ids=media_ids)
except MastodonAPIError as e: except MastodonAPIError as e:
_, _, _, exception_message = e.args _, status_code, _, exception_message = e.args
if exception_message.find('Text character limit') != -1: if status_code == 500:
logging.error('Mastodon internal server error')
logging.error('posting ' + tweet['tweet_id'] + ' to ' + TOML['config']['mastodon_instance'] + ' Failed')
continue
elif exception_message.find('Text character limit') != -1:
# ERROR (('Mastodon API returned error', 422, 'Unprocessable Entity', 'Validation failed: Text character limit of 500 exceeded')) # ERROR (('Mastodon API returned error', 422, 'Unprocessable Entity', 'Validation failed: Text character limit of 500 exceeded'))
logging.error('Toot text too long: %s characters', str(len(tweet['tweet_text']))) logging.error('Toot text too long: %s characters', str(len(tweet['tweet_text'])))
logging.error('posting ' + tweet['tweet_id'] + ' to ' + TOML['config']['mastodon_instance'] + ' Failed') logging.error('posting ' + tweet['tweet_id'] + ' to ' + TOML['config']['mastodon_instance'] + ' Failed')