fix: handle json decode error

This commit is contained in:
0xMRTT 2023-05-26 20:01:17 +02:00
parent e36e58c1c8
commit 85fc78a222
Signed by: 0xMRTT
GPG Key ID: 910B287304120902

View File

@ -36,14 +36,21 @@ class StableDiffusionLocalProvider(ImaginerProvider):
self.no_api_key() self.no_api_key()
return "" return ""
elif response.status_code != 200: elif response.status_code != 200:
try:
self.no_api_key(title=response.json()["error"]) self.no_api_key(title=response.json()["error"])
return "" return ""
except json.decoder.JSONDecodeError:
self.no_api_key(title="No response")
return ""
response = response.json() response = response.json()
except KeyError: except KeyError:
pass pass
except socket.gaierror: except socket.gaierror:
self.no_connection() self.no_connection()
return "" return ""
except json.decoder.JSONDecodeError:
self.no_api_key(title="No response")
return ""
else: else:
self.hide_banner() self.hide_banner()
if response: if response: