From: Carl Worth Date: Thu, 8 Dec 2022 01:05:58 +0000 (-0800) Subject: Add exception handling to execution of image generation script X-Git-Url: https://git.cworth.org/git?a=commitdiff_plain;h=154c44e9c5d3edd5d7495ef17d8357f334cb900c;p=zombocom-ai Add exception handling to execution of image generation script So that if the script fails for some reason, the server doesn't crash. --- diff --git a/index.js b/index.js index ba01d67..638c59d 100644 --- a/index.js +++ b/index.js @@ -84,7 +84,11 @@ io.on('connection', (socket) => { child.stderr.on('data', (data) => { console.log("Error occurred during generate-image: " + data); }); - const { stdout, stderr } = await promise; + try { + const { stdout, stderr } = await promise; + } catch(e) { + console.error(e); + } socket.emit('generation-done'); } generate_image(request['code'], request['prompt']);