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()
return ""
elif response.status_code != 200:
try:
self.no_api_key(title=response.json()["error"])
return ""
except json.decoder.JSONDecodeError:
self.no_api_key(title="No response")
return ""
response = response.json()
except KeyError:
pass
except socket.gaierror:
self.no_connection()
return ""
except json.decoder.JSONDecodeError:
self.no_api_key(title="No response")
return ""
else:
self.hide_banner()
if response: