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) { export function createResponse(responseType, responseData) {
const internalError = (text) => {
return {
status: 500,
body: {
status: "error",
text: text || "Internal Server Error",
critical: true
}
}
}
try { try {
let status = 200, let status = 200,
response = {}; response = {};
@ -72,6 +83,8 @@ export function createResponse(responseType, responseData) {
audio: audio audio: audio
} }
break; break;
case "critical":
return internalError(responseData.t)
default: default:
throw "unreachable" throw "unreachable"
} }
@ -83,13 +96,7 @@ export function createResponse(responseType, responseData) {
} }
} }
} catch { } catch {
return { return internalError()
status: 500,
body: {
status: "error",
text: "Internal Server Error"
}
}
} }
} }