From c068557c0c4e7e20d7bee208eaebd22ca46ff1c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Jastrz=C4=99bski?= Date: Wed, 8 May 2024 16:42:25 +0200 Subject: [PATCH] Handle properly scenario where Wago Addons is down (close #384) --- CB/Core.py | 2 +- CB/WagoAddons.py | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/CB/Core.py b/CB/Core.py index c45187c..2c9a462 100644 --- a/CB/Core.py +++ b/CB/Core.py @@ -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.') diff --git a/CB/WagoAddons.py b/CB/WagoAddons.py index a322223..b3354be 100644 --- a/CB/WagoAddons.py +++ b/CB/WagoAddons.py @@ -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()