From 645503d0fe3216ce7f076ca505106b5aa461ac18 Mon Sep 17 00:00:00 2001 From: db0 Date: Thu, 7 Sep 2023 20:27:21 +0200 Subject: [PATCH] retrieve more info on error --- fediseer/fediverse.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/fediseer/fediverse.py b/fediseer/fediverse.py index 6f9f7e8..de59563 100644 --- a/fediseer/fediverse.py +++ b/fediseer/fediverse.py @@ -12,11 +12,16 @@ def get_lemmy_admins(domain): return [a["person"]["name"] for a in site["admins"]] def get_mastodon_admins(domain): + site = None try: - site = requests.get(f"https://{domain}/api/v2/instance").json() - return [site["contact"]["account"]["username"]] + site = requests.get(f"https://{domain}/api/v2/instance") + site_json = site.json() + return [site_json["contact"]["account"]["username"]] except Exception as err: - logger.warning(f"Error retrieving mastodon site info for {domain}: {err}") + if site is not None: + logger.warning(f"Error retrieving mastodon site info for {domain}: {err}. Request text: {site.text()}") + else: + logger.warning(f"Error retrieving mastodon site info for {domain}: {err}") raise Exception(f"Error retrieving mastodon site info for {domain}: {err}") def get_unknown_admins(domain):