MCPcopy Create free account
hub / github.com/MCSManager/MCSManager / responseError

Function responseError

daemon/src/service/protocol.ts:50–71  ·  view source on GitHub ↗
(
  ctx: RouterContext,
  err: Error | string,
  config?: IResponseErrorConfig
)

Source from the content-addressed store, hash-verified

48}
49
50export function responseError(
51 ctx: RouterContext,
52 err: Error | string,
53 config?: IResponseErrorConfig
54) {
55 let errinfo: any = "";
56 if (err) errinfo = err.toString();
57 else errinfo = err;
58 const packet = new Packet(ctx.uuid, STATUS_ERR, ctx.event, errinfo);
59 // Ignore
60 if (String(err).includes(IGNORE) && ctx.event) return ctx.socket.emit(ctx.event, packet);
61 if (!config?.disablePrint)
62 logger.warn(
63 $t("TXT_CODE_protocol.socketErr", {
64 id: ctx.socket.id,
65 address: ctx.socket.handshake.address,
66 event: ctx.event
67 }),
68 err
69 );
70 if (ctx.event) ctx.socket.emit(ctx.event, packet);
71}
72
73export function msg(ctx: RouterContext, event: string, data: any) {
74 const packet = new Packet(ctx.uuid, STATUS_OK, event, data);

Callers 1

emitRouterMethod · 0.90

Calls 2

$tFunction · 0.90
emitMethod · 0.80

Tested by

no test coverage detected