Skip to content

Commit

Permalink
Handle properly scenario where Wago Addons is down (close #384)
Browse files Browse the repository at this point in the history
  • Loading branch information
AcidWeb committed May 9, 2024
1 parent c1c165e commit c068557
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion CB/Core.py
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,7 @@ def parse_wagoaddons_error(self, code):
raise RuntimeError('Provided Wago Addons API key is expired. Please acquire a new one.')
elif code == 423:
raise RuntimeError('Provided Wago Addons API key is blocked. Please acquire a new one.')
elif code in [429, 500]:
elif code in [429, 500, 502, 504]:
raise RuntimeError('Temporary Wago Addons API issue. Please try later.')


Expand Down
8 changes: 5 additions & 3 deletions CB/WagoAddons.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,14 @@ def __init__(self, url, checkcache, clienttype, allowdev, apikey, http):
raise RuntimeError(f'{url}\nWago Addons API key is missing or incorrect.')
elif self.payload.status_code == 403:
raise RuntimeError(f'{url}\nProvided Wago Addons API key is expired. Please acquire a new one.')
elif self.payload.status_code == 423:
raise RuntimeError(f'{url}\nProvided Wago Addons API key is blocked. Please acquire a new one.')
elif self.payload.status_code in {404, 429, 500}:
elif self.payload.status_code == 404:
raise RuntimeError(f'{url}\nThis might be a temporary issue with Wago Addons API or the project was '
f'removed/renamed. In this case, uninstall it (and reinstall if it still exists) '
f'to fix this issue.')
elif self.payload.status_code == 423:
raise RuntimeError(f'{url}\nProvided Wago Addons API key is blocked. Please acquire a new one.')
elif self.payload.status_code in [429, 500, 502, 504]:
raise RuntimeError(f'{url}\nTemporary Wago Addons API issue. Please try later.')
else:
try:
self.payload = self.payload.json()
Expand Down

0 comments on commit c068557

Please sign in to comment.