MCPcopy Index your code
hub / github.com/scriptscat/scriptcat / formatErrorToClient

Function formatErrorToClient

packages/message/server.ts:116–127  ·  view source on GitHub ↗
(e: any)

Source from the content-addressed store, hash-verified

114type MiddlewareFunction = (params: any, con: IGetSender, next: () => Promise<any> | any) => Promise<any> | any;
115
116const formatErrorToClient = (e: any) => {
117 if (!e) return `${e}`;
118 if (typeof e?.message === "string") return e.message;
119 if (typeof e === "object") {
120 try {
121 return JSON.stringify(e);
122 } catch {
123 // ignored
124 }
125 }
126 return e.toString();
127};
128
129export class Server {
130 private apiFunctionMap: Map<string, ApiFunction> = new Map();

Callers 2

connectHandleMethod · 0.85
messageHandleMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected