Files
TrueGrowth/vendor/aigcpanel/electron/mapi/server/error.ts
Jammy 52636c91ae
Some checks failed
CI / main (push) Has been cancelled
CI / release-e2e (push) Has been cancelled
Track bundled vendor runtime sources
2026-07-07 10:05:50 +08:00

25 lines
658 B
TypeScript

export const mapError = (e) => {
let msg = e;
if (e instanceof Error) {
msg = [e.message, e.stack].join("\n");
} else if (typeof e !== "string") {
msg = e.toString();
}
const map = {
// 'fetch error': '网络错误',
};
for (let key in map) {
if (msg.includes(key)) {
let error = map[key];
// regex PluginReleaseDocFormatError:-11
const regex = new RegExp(`${key}:(-?\\d+)`);
const match = msg.match(regex);
if (match) {
error += `(${match[1]})`;
}
return error;
}
}
return msg;
};