mirror of
https://github.com/hughrun/ephemetoot
synced 2025-02-18 12:40:41 +01:00
improve exception handling
This commit is contained in:
parent
6dfb599155
commit
3f6562b423
@ -1,12 +1,14 @@
|
||||
import json
|
||||
from mastodon import Mastodon, MastodonError
|
||||
from mastodon import Mastodon, MastodonError, MastodonAPIError, MastodonNetworkError
|
||||
from datetime import datetime, timedelta, timezone
|
||||
import time
|
||||
import requests
|
||||
|
||||
def checkToots(config, options, deleted_count=0):
|
||||
if options.test:
|
||||
print("This is a test run...")
|
||||
print("Fetching account details for @" + config['username'] + "@" + config['base_url'] + "...")
|
||||
try:
|
||||
mastodon = Mastodon(
|
||||
access_token=config['access_token'],
|
||||
api_base_url="https://" + config['base_url'],
|
||||
@ -108,3 +110,11 @@ def checkToots(config, options, deleted_count=0):
|
||||
print("Removed " + str(deleted_count) + " toots.")
|
||||
except IndexError:
|
||||
print("No toots found!")
|
||||
|
||||
except MastodonAPIError:
|
||||
print('User and/or access token does not exist or has been deleted')
|
||||
except MastodonNetworkError:
|
||||
print('ephemetoot cannot connect to the server - are you online?')
|
||||
finally:
|
||||
print('🥳 ==> 🧼 ==> 😇 User cleanup complete!')
|
||||
print('---------------------------------------')
|
Loading…
x
Reference in New Issue
Block a user