Skip to content

Commit

Permalink
Fix tests in a more pytonic way as proposed by @dlax
Browse files Browse the repository at this point in the history
  • Loading branch information
blogh committed Aug 21, 2023
1 parent 28bbfe9 commit 01087de
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion check_patroni/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,10 @@ def rest_api(self: "PatroniResource", service: str) -> Any:
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")


Expand Down

0 comments on commit 01087de

Please sign in to comment.