Fix tests in a more pytonic way as proposed by @dlax

This commit is contained in:
benoit 2023-08-21 14:56:02 +02:00 committed by Benoit
parent 77722f40c1
commit d07a26d324

View file

@ -69,7 +69,10 @@ class PatroniResource(nagiosplugin.Resource):
f"Failed to connect to {endpoint}/{service} status code {r.status_code}"
)
return r.json() if r.text else None
try:
return r.json()
except requests.exceptions.JSONDecodeError:
return None
raise nagiosplugin.CheckError("Connection failed for all provided endpoints")