MCPcopy
hub / github.com/modstart-lib/aigcpanel / mapError

Function mapError

electron/mapi/server/error.ts:1–24  ·  view source on GitHub ↗
(e)

Source from the content-addressed store, hash-verified

1export const mapError = (e) => {
2 let msg = e;
3 if (e instanceof Error) {
4 msg = [e.message, e.stack].join("\n");
5 } else if (typeof e !== "string") {
6 msg = e.toString();
7 }
8 const map = {
9 // 'fetch error': '网络错误',
10 };
11 for (let key in map) {
12 if (msg.includes(key)) {
13 let error = map[key];
14 // regex PluginReleaseDocFormatError:-11
15 const regex = new RegExp(`${key}:(-?\\d+)`);
16 const match = msg.match(regex);
17 if (match) {
18 error += `(${match[1]})`;
19 }
20 return error;
21 }
22 }
23 return msg;
24};

Callers 2

getModuleFunction · 0.90
main.tsFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected