From dd778355999687d86111552de8042aea3a1f12ce Mon Sep 17 00:00:00 2001 From: wukko Date: Wed, 15 May 2024 21:55:14 +0600 Subject: [PATCH] request: add missing critical error --- src/modules/processing/request.js | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/modules/processing/request.js b/src/modules/processing/request.js index 9015e742..9b7af098 100644 --- a/src/modules/processing/request.js +++ b/src/modules/processing/request.js @@ -22,6 +22,17 @@ const apiVar = { } export function createResponse(responseType, responseData) { + const internalError = (text) => { + return { + status: 500, + body: { + status: "error", + text: text || "Internal Server Error", + critical: true + } + } + } + try { let status = 200, response = {}; @@ -72,6 +83,8 @@ export function createResponse(responseType, responseData) { audio: audio } break; + case "critical": + return internalError(responseData.t) default: throw "unreachable" } @@ -83,13 +96,7 @@ export function createResponse(responseType, responseData) { } } } catch { - return { - status: 500, - body: { - status: "error", - text: "Internal Server Error" - } - } + return internalError() } }