MCPcopy Create free account
hub / github.com/PageLeay/celestial-runtime / makeError

Function makeError

lib.esm/utils/errors.js:95–142  ·  view source on GitHub ↗
(message, code, info)

Source from the content-addressed store, hash-verified

93 * ethers version, %%code%% and all additional properties, serialized.
94 */
95export function makeError(message, code, info) {
96 let shortMessage = message;
97 {
98 const details = [];
99 if (info) {
100 if ("message" in info || "code" in info || "name" in info) {
101 throw new Error(`value will overwrite populated values: ${stringify(info)}`);
102 }
103 for (const key in info) {
104 if (key === "shortMessage") {
105 continue;
106 }
107 const value = (info[key]);
108 // try {
109 details.push(key + "=" + stringify(value));
110 // } catch (error: any) {
111 // console.log("MMM", error.message);
112 // details.push(key + "=[could not serialize object]");
113 // }
114 }
115 }
116 details.push(`code=${code}`);
117 details.push(`version=${version}`);
118 if (details.length) {
119 message += " (" + details.join(", ") + ")";
120 }
121 }
122 let error;
123 switch (code) {
124 case "INVALID_ARGUMENT":
125 error = new TypeError(message);
126 break;
127 case "NUMERIC_FAULT":
128 case "BUFFER_OVERRUN":
129 error = new RangeError(message);
130 break;
131 default:
132 error = new Error(message);
133 }
134 defineProperties(error, { code });
135 if (info) {
136 Object.assign(error, info);
137 }
138 if (error.shortMessage == null) {
139 defineProperties(error, { shortMessage });
140 }
141 return error;
142}
143/**
144 * Throws an EthersError with %%message%%, %%code%% and additional error
145 * %%info%% when %%check%% is falsish..

Callers 15

getUrlFunction · 0.90
getUrlFunction · 0.90
waitForTransactionMethod · 0.90
finalizeMethod · 0.90
waitMethod · 0.90
checkTxMethod · 0.90
#scheduleDrainFunction · 0.90
_startFunction · 0.90
getRpcErrorFunction · 0.90
sendFunction · 0.90
destroyFunction · 0.90
_processMessageMethod · 0.90

Calls 3

definePropertiesFunction · 0.90
stringifyFunction · 0.70
joinMethod · 0.45

Tested by

no test coverage detected