escape Mastodon API Errors & Mastodon Network Errors #5

Closed
opened 2019-06-10 09:41:01 +00:00 by b3yond · 1 comment

Author: @b3yond Posted at: 29.12.2017 17:28

If there are problems with the Mastodon server, usually our bot crashes too. Several tracebacks to track down the issue:

[...]

Traceback (most recent call last):
  File "ticketfrei.py", line 29, in <module>
    statuses = mbot.retoot(statuses)
  File "/home/ticketfrei/ticketfrei/retootbot.py", line 85, in retoot
    for notification in self.m.notifications():
  File "/home/ticketfrei/ticketfrei/local/lib/python2.7/site-packages/mastodon/Mastodon.py", line 365, in notifications
    return self.__api_request('GET', '/api/v1/notifications', params)
  File "/home/ticketfrei/ticketfrei/local/lib/python2.7/site-packages/mastodon/Mastodon.py", line 1124, in __api_request
    raise MastodonAPIError('General API problem.')
MastodonAPIError: General API problem.
[2017-12-14 10:00:43.182977] Shit went wrong, closing down. Sending message to links_tech
(ticketfrei) ticketfrei@mumble:~/ticketfrei$ python ticketfrei.py
Path of logfile: logs/2017-12-17 18:46:52.297668
Traceback (most recent call last):
  File "ticketfrei.py", line 29, in <module>
    statuses = mbot.retoot(statuses)
  File "/home/ticketfrei/ticketfrei/retootbot.py", line 85, in retoot
    for notification in self.m.notifications():
  File "/home/ticketfrei/ticketfrei/local/lib/python2.7/site-packages/mastodon/Mastodon.py", line 365, in notifications
    return self.__api_request('GET', '/api/v1/notifications', params)
  File "/home/ticketfrei/ticketfrei/local/lib/python2.7/site-packages/mastodon/Mastodon.py", line 1124, in __api_request
    raise MastodonAPIError('General API problem.')
MastodonAPIError: General API problem.
[2017-12-19 02:36:42.146528] Shit went wrong, closing down. Sending message to links_tech
(ticketfrei) ticketfrei@mumble:~/ticketfrei$ python ticketfrei.py
Path of logfile: logs/2017-12-21 12:18:56.142208
Traceback (most recent call last):
  File "ticketfrei.py", line 29, in <module>
    statuses = mbot.retoot(statuses)
  File "/home/ticketfrei/ticketfrei/retootbot.py", line 85, in retoot
    for notification in self.m.notifications():
  File "/home/ticketfrei/ticketfrei/local/lib/python2.7/site-packages/mastodon/Mastodon.py", line 365, in notifications
    return self.__api_request('GET', '/api/v1/notifications', params)
  File "/home/ticketfrei/ticketfrei/local/lib/python2.7/site-packages/mastodon/Mastodon.py", line 1081, in __api_request
    raise MastodonNetworkError("Could not complete request: %s" % e)
MastodonNetworkError: Could not complete request: HTTPSConnectionPool(host='chaos.social', port=443): Max retries exceeded with url: /api/v1/notifications (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7fd79e1c1c10>: Failed to establish a new connection: [Errno 110] Connection timed out',))
[2017-12-21 21:10:17.711390] Shit went wrong, closing down. Sending message to links_tech

I'm not sure if the Mastodon library treats Errors properly - I think the last time I tried to fix this, I couldn't escape them. Maybe try to look it up in the git history.

Author: @b3yond Posted at: 29.12.2017 17:28 If there are problems with the Mastodon server, usually our bot crashes too. Several tracebacks to track down the issue: ``` [...] Traceback (most recent call last): File "ticketfrei.py", line 29, in <module> statuses = mbot.retoot(statuses) File "/home/ticketfrei/ticketfrei/retootbot.py", line 85, in retoot for notification in self.m.notifications(): File "/home/ticketfrei/ticketfrei/local/lib/python2.7/site-packages/mastodon/Mastodon.py", line 365, in notifications return self.__api_request('GET', '/api/v1/notifications', params) File "/home/ticketfrei/ticketfrei/local/lib/python2.7/site-packages/mastodon/Mastodon.py", line 1124, in __api_request raise MastodonAPIError('General API problem.') MastodonAPIError: General API problem. [2017-12-14 10:00:43.182977] Shit went wrong, closing down. Sending message to links_tech (ticketfrei) ticketfrei@mumble:~/ticketfrei$ python ticketfrei.py Path of logfile: logs/2017-12-17 18:46:52.297668 Traceback (most recent call last): File "ticketfrei.py", line 29, in <module> statuses = mbot.retoot(statuses) File "/home/ticketfrei/ticketfrei/retootbot.py", line 85, in retoot for notification in self.m.notifications(): File "/home/ticketfrei/ticketfrei/local/lib/python2.7/site-packages/mastodon/Mastodon.py", line 365, in notifications return self.__api_request('GET', '/api/v1/notifications', params) File "/home/ticketfrei/ticketfrei/local/lib/python2.7/site-packages/mastodon/Mastodon.py", line 1124, in __api_request raise MastodonAPIError('General API problem.') MastodonAPIError: General API problem. [2017-12-19 02:36:42.146528] Shit went wrong, closing down. Sending message to links_tech (ticketfrei) ticketfrei@mumble:~/ticketfrei$ python ticketfrei.py Path of logfile: logs/2017-12-21 12:18:56.142208 Traceback (most recent call last): File "ticketfrei.py", line 29, in <module> statuses = mbot.retoot(statuses) File "/home/ticketfrei/ticketfrei/retootbot.py", line 85, in retoot for notification in self.m.notifications(): File "/home/ticketfrei/ticketfrei/local/lib/python2.7/site-packages/mastodon/Mastodon.py", line 365, in notifications return self.__api_request('GET', '/api/v1/notifications', params) File "/home/ticketfrei/ticketfrei/local/lib/python2.7/site-packages/mastodon/Mastodon.py", line 1081, in __api_request raise MastodonNetworkError("Could not complete request: %s" % e) MastodonNetworkError: Could not complete request: HTTPSConnectionPool(host='chaos.social', port=443): Max retries exceeded with url: /api/v1/notifications (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7fd79e1c1c10>: Failed to establish a new connection: [Errno 110] Connection timed out',)) [2017-12-21 21:10:17.711390] Shit went wrong, closing down. Sending message to links_tech ``` I'm not sure if the Mastodon library treats Errors properly - I think the last time I tried to fix this, I couldn't escape them. Maybe try to look it up in the git history.
Author

Author: @b3yond Posted at: 26.03.2018 19:26

the library does not allow to except those 2 errors specifically. A shame. For now, I escaped the statements where they can be raised, so nothing breaks when the mastodon instance is having problems.

Author: @b3yond Posted at: 26.03.2018 19:26 the library does not allow to except those 2 errors specifically. A shame. For now, I escaped the statements where they can be raised, so nothing breaks when the mastodon instance is having problems.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: juergen/ticketfrei#5
No description provided.