Fix tests in a more pytonic way as proposed by @dlax
This commit is contained in:
parent
77722f40c1
commit
d07a26d324
|
@ -69,7 +69,10 @@ class PatroniResource(nagiosplugin.Resource):
|
||||||
f"Failed to connect to {endpoint}/{service} status code {r.status_code}"
|
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")
|
raise nagiosplugin.CheckError("Connection failed for all provided endpoints")
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue