Include error message on generic websocket error

This commit is contained in:
Rory&
2026-09-03 11:05:50 +02:00
parent a7eb513f9d
commit cc71e67a35
+4 -1
View File
@@ -25,6 +25,7 @@ import WS from "ws";
import OPCodeHandlers from "../opcodes";
import { check } from "../opcodes/instanceOf";
import { PayloadSchema } from "@spacebar/schemas";
import { HTTPError } from "lambert-server";
const bigIntJson = BigIntJson({ storeAsString: true });
@@ -90,7 +91,9 @@ export async function Message(this: WebSocket, buffer: WS.Data) {
return await OPCodeHandler.call(this, data);
} catch (error) {
console.error(`[Gateway/${this.user_id ?? this.ipAddress}] Error: Op ${data.op}`, error);
let message: string | undefined = undefined;
if (error instanceof HTTPError) message = error.message;
// if (!this.CLOSED && this.CLOSING)
return this.close(CLOSECODES.Unknown_error);
return this.close(CLOSECODES.Unknown_error, message ?? `Unknown opcode error while handling opcode ${data.op}`);
}
}