Give a more specfic error message if we can't add an account to list

This commit is contained in:
Daniel Schwarz 2023-03-26 21:51:29 -04:00 committed by Ivan Habunek
parent 47b182a05b
commit e85f7ce594
No known key found for this signature in database
GPG Key ID: CDBD63C43A30BB95
1 changed files with 17 additions and 1 deletions

View File

@ -463,7 +463,23 @@ def list_add(app, user, args):
if not account:
print_out("<red>Account not found</red>")
return
api.add_accounts_to_list(app, user, list_id, [account['id']])
try:
api.add_accounts_to_list(app, user, list_id, [account['id']])
except Exception as ex:
# if we failed to add the account, try to give a
# more specific error message than "record not found"
my_accounts = api.followers(app, user, account['id'])
found = False
if my_accounts:
for my_account in my_accounts:
if my_account['id'] == account['id']:
found = True
break
if found is False:
print_out(f"<red>You must follow @{account['acct']} before adding this account to a list.</red>")
else:
print_out(f"<red>{ex}</red>")
return
print_out(f"<green>✓ Added account \"{args.account}\"</green>")