From 71c45e1b417ecc478b9caa033d767090f07c8268 Mon Sep 17 00:00:00 2001 From: Jack Date: Mon, 24 Mar 2025 06:54:56 +0200 Subject: [PATCH] Catch JSON Errors --- __init__.py | 2 +- modules/utils/runwareUtils.py | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/__init__.py b/__init__.py index 88357d3..a10eed8 100644 --- a/__init__.py +++ b/__init__.py @@ -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" diff --git a/modules/utils/runwareUtils.py b/modules/utils/runwareUtils.py index 31bb51c..0dd5b2d 100644 --- a/modules/utils/runwareUtils.py +++ b/modules/utils/runwareUtils.py @@ -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: