Catch JSON Errors
This commit is contained in:
+1
-1
@@ -19,7 +19,7 @@ from .modules.ipAdapter import ipAdapter
|
||||
from .modules.ipAdapterCombine import ipAdapterCombine
|
||||
from .modules.vaeSearch import vaeSearch
|
||||
|
||||
RUNWARE_COMFYUI_VERSION = "1.0.4 Beta"
|
||||
RUNWARE_COMFYUI_VERSION = "1.0.5 Beta"
|
||||
|
||||
RESET_COLOR = "\033[0m"
|
||||
BLUE_COLOR = "\033[94m"
|
||||
|
||||
@@ -256,7 +256,7 @@ def inferenecRequest(genConfig):
|
||||
try:
|
||||
|
||||
def recaller():
|
||||
return session.post(
|
||||
response = session.post(
|
||||
RUNWARE_API_BASE_URL,
|
||||
headers=headers,
|
||||
json=genConfig,
|
||||
@@ -264,9 +264,17 @@ def inferenecRequest(genConfig):
|
||||
allow_redirects=False,
|
||||
stream=True,
|
||||
)
|
||||
if response.status_code != 200:
|
||||
print(f"[Debugging] Runware Response Status Code: {response.status_code}")
|
||||
return response
|
||||
|
||||
genResult = generalRequestWrapper(recaller)
|
||||
genResult = genResult.json()
|
||||
try:
|
||||
genResult = genResult.json()
|
||||
except json.JSONDecodeError as e:
|
||||
print(f"[Debugging] Runware JSON Decode Error: {str(e)}")
|
||||
print(f"[Debugging] Runware Raw Response Content: {genResult.content}")
|
||||
raise Exception("Error: Invalid JSON response from API!")
|
||||
if "errors" in genResult:
|
||||
raise Exception(genResult["errors"][0]["message"])
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user