diff --git a/src/gateway/events/Message.ts b/src/gateway/events/Message.ts index 7a2e49d3d..b76ab889a 100644 --- a/src/gateway/events/Message.ts +++ b/src/gateway/events/Message.ts @@ -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}`); } }