| 76 | } |
| 77 | |
| 78 | export function error(ctx: RouterContext, event: string, err: any, config?: IResponseErrorConfig) { |
| 79 | const packet = new Packet(ctx.uuid, STATUS_ERR, event, err); |
| 80 | // Ignore |
| 81 | if (String(err).includes(IGNORE) && ctx.event) return ctx.socket.emit(ctx.event, packet); |
| 82 | if (!config?.disablePrint) |
| 83 | logger.warn( |
| 84 | $t("TXT_CODE_protocol.socketErr", { |
| 85 | id: ctx.socket.id, |
| 86 | address: ctx.socket.handshake.address, |
| 87 | event: ctx.event |
| 88 | }), |
| 89 | err |
| 90 | ); |
| 91 | |
| 92 | ctx.socket.emit(event, packet); |
| 93 | } |
| 94 | |
| 95 | export function parse(text: IPacket) { |
| 96 | if (typeof text == "object") { |