add error handling

This commit is contained in:
marlon-erler
2024-07-08 20:55:28 +02:00
parent 49b4ed94f6
commit 85164a4e0a
+13
View File
@@ -11,6 +11,7 @@ import {
import { import {
createFileResponse, createFileResponse,
getVersionNumber, getVersionNumber,
writeError,
writeStatNumber, writeStatNumber,
writeStatString, writeStatString,
writeSuccess, writeSuccess,
@@ -59,13 +60,25 @@ async function main() {
websocket: { websocket: {
open(ws) { open(ws) {
try {
trackConnection(ws); trackConnection(ws);
} catch (error) {
writeError(error);
}
}, },
message(ws, message) { message(ws, message) {
try {
processMessage(ws, message.toString(), config); processMessage(ws, message.toString(), config);
} catch (error) {
writeError(error);
}
}, },
close(ws) { close(ws) {
try {
forgetConnection(ws); forgetConnection(ws);
} catch (error) {
writeError(error);
}
}, },
}, },