mirror of
https://github.com/spacebarchat/server.git
synced 2026-09-17 18:56:46 +00:00
Include error message on generic websocket error
This commit is contained in:
@@ -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}`);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user