add error handling
This commit is contained in:
@@ -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);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user