request: add missing critical error

This commit is contained in:
wukko 2024-05-15 21:55:14 +06:00
parent cc6345ff63
commit dd77835599
No known key found for this signature in database
GPG key ID: 3E30B3F26C7B4AA2

View file

@ -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()
}
}