From e7b9d2c02cffd59fecca4ee617137ea38641078a Mon Sep 17 00:00:00 2001 From: comfyanonymous Date: Sun, 14 May 2023 01:30:58 -0400 Subject: [PATCH] /prompt endpoint error is now in json format. --- server.py | 7 +++---- web/scripts/api.js | 2 +- web/scripts/app.js | 2 +- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/server.py b/server.py index ba4dcba0..f52117f1 100644 --- a/server.py +++ b/server.py @@ -323,12 +323,11 @@ class PromptServer(): self.prompt_queue.put((number, prompt_id, prompt, extra_data, valid[2])) return web.json_response({"prompt_id": prompt_id}) else: - resp_code = 400 - out_string = valid[1] print("invalid prompt:", valid[1]) + return web.json_response({"error": valid[1]}, status=400) + else: + return web.json_response({"error": "no prompt"}, status=400) - return web.Response(body=out_string, status=resp_code) - @routes.post("/queue") async def post_queue(request): json_data = await request.json() diff --git a/web/scripts/api.js b/web/scripts/api.js index d29faa5b..4f061c35 100644 --- a/web/scripts/api.js +++ b/web/scripts/api.js @@ -163,7 +163,7 @@ class ComfyApi extends EventTarget { if (res.status !== 200) { throw { - response: await res.text(), + response: await res.json(), }; } } diff --git a/web/scripts/app.js b/web/scripts/app.js index 1a4a18b9..00d3c974 100644 --- a/web/scripts/app.js +++ b/web/scripts/app.js @@ -1222,7 +1222,7 @@ export class ComfyApp { try { await api.queuePrompt(number, p); } catch (error) { - this.ui.dialog.show(error.response || error.toString()); + this.ui.dialog.show(error.response.error || error.toString()); break; }