robertoszek / pleroma-bot

Bot for mirroring one or multiple Twitter accounts in Pleroma/Mastodon/Misskey.
https://robertoszek.github.io/pleroma-bot
MIT License
104 stars 18 forks source link

Handle exception when the bio_text is too long #44

Closed nemobis closed 3 years ago

nemobis commented 3 years ago

I didn't realise that the original Twitter bio is appended to the text provided via bio_text, so I ended up having too much text. That produced the error:

2021-04-29 08:33:06,479 pleroma_bot ERROR: Exception occurred
Traceback (most recent call last):
  File "/home/federico/git/federico/mastodon/lib64/python3.9/site-packages/pleroma_bot/cli.py", line 435, in main
    user.update_pleroma()
  File "/home/federico/git/federico/mastodon/lib64/python3.9/site-packages/pleroma_bot/_pleroma.py", line 243, in update_pleroma
    response.raise_for_status()
  File "/home/federico/git/federico/mastodon/lib64/python3.9/site-packages/requests/models.py", line 943, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 422 Client Error: Unprocessable Entity for url: https://mastodon.technology/api/v1/accounts/update_credentials

(Oddly, the update seemed to go through, or at least the profile images were updated at some point.) Verified by shortening the text and seeing the error went away.

The error is not particularly useful. At a minimum it could be a good idea to remind the user to check the variables which might make the request fail, perhaps?

robertoszek commented 3 years ago

Hi! You raise a good point, I changed the output of the exception for error code 422 when updating the profile so it's a little more readable an user-friendly when it comes to identifying what caused it.

82c776b802d8305d118b89c30e3338029e1b554f