MCPcopy
hub / github.com/AstrBotDevs/AstrBot / resolveErrorMessage

Function resolveErrorMessage

dashboard/src/utils/errorUtils.js:21–44  ·  view source on GitHub ↗
(err, fallbackMessage = "")

Source from the content-addressed store, hash-verified

19};
20
21export const resolveErrorMessage = (err, fallbackMessage = "") => {
22 if (typeof err === "string") {
23 return err.trim() || fallbackMessage;
24 }
25 if (typeof err === "number" || typeof err === "boolean") {
26 return String(err);
27 }
28
29 const fromResponse =
30 pickResponseMessage(err?.response?.data) ||
31 (typeof err?.response?.statusText === "string"
32 ? err.response.statusText.trim()
33 : "");
34 const fromError =
35 typeof err?.message === "string" ? err.message.trim() : "";
36
37 let fromString = "";
38 if (typeof err?.toString === "function") {
39 const value = err.toString().trim();
40 fromString = INVALID_ERROR_STRINGS.has(value) ? "" : value;
41 }
42
43 return fromResponse || fromError || fromString || fallbackMessage;
44};

Callers 6

reloadFailedPluginFunction · 0.90
uninstallFunction · 0.90
reloadPluginFunction · 0.90
resolveCustomSourceFunction · 0.90
newExtensionFunction · 0.90

Calls 2

pickResponseMessageFunction · 0.85
toStringMethod · 0.45

Tested by

no test coverage detected