MCPcopy Create free account
hub / github.com/MetaMask/rpc-errors / serializeCause

Function serializeCause

src/utils.ts:205–224  ·  view source on GitHub ↗
(error: unknown)

Source from the content-addressed store, hash-verified

203 * @returns A JSON-serializable object containing as much information about the original error as possible.
204 */
205export function serializeCause(error: unknown): Json {
206 if (Array.isArray(error)) {
207 return error.map((entry) => {
208 if (isValidJson(entry)) {
209 return entry;
210 } else if (isObject(entry)) {
211 return serializeObject(entry);
212 }
213 return null;
214 });
215 } else if (isObject(error)) {
216 return serializeObject(error);
217 }
218
219 if (isValidJson(error)) {
220 return error;
221 }
222
223 return null;
224}
225
226/**
227 * Extracts all JSON-serializable properties from an object.

Callers 2

serializeMethod · 0.90
buildErrorFunction · 0.85

Calls 1

serializeObjectFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…