Improve error handling in Prosody version retrieval

This commit is contained in:
Jonas Schäfer
2021-03-09 22:20:37 +01:00
parent 6de1e5313f
commit 025172592f

View File

@@ -514,9 +514,16 @@ class ProsodyClient:
} }
async with session.post(self._rest_endpoint, data=req) as resp: async with session.post(self._rest_endpoint, data=req) as resp:
if resp.status != 200:
return "unknwn"
try: try:
return (await resp.json())["version"]["version"] return (await resp.json())["version"]["version"]
except: except Exception as exc:
self.logger.debug(
"failed to parse prosody version from response"
" (%s: %s)",
type(exc), exc,
)
return "unknown" return "unknown"
@autosession @autosession