register_server: Improve HTTP error reporting.

This commit is contained in:
Tim Abbott 2022-01-21 15:02:30 -08:00
parent fb09c18462
commit 367fed89f2
1 changed files with 7 additions and 2 deletions

View File

@ -118,8 +118,13 @@ class Command(ZulipBaseCommand):
)
try:
response.raise_for_status()
except requests.HTTPError:
content_dict = response.json()
except requests.HTTPError as e:
# Report nice errors from the Zulip API if possible.
try:
content_dict = response.json()
except Exception:
raise e
raise CommandError("Error: " + content_dict["msg"])
return response