MCPcopy Create free account
hub / github.com/agentrpc/agentrpc / serializeError

Function serializeError

sdk-node/src/serialize-error.js:183–205  ·  view source on GitHub ↗
(value, options = {})

Source from the content-addressed store, hash-verified

181};
182
183export function serializeError(value, options = {}) {
184 const { maxDepth = Number.POSITIVE_INFINITY, useToJSON = true } = options;
185
186 if (typeof value === "object" && value !== null) {
187 return destroyCircular({
188 from: value,
189 seen: [],
190 forceEnumerable: true,
191 maxDepth,
192 depth: 0,
193 useToJSON,
194 serialize: true,
195 });
196 }
197
198 // People sometimes throw things besides Error objects…
199 if (typeof value === "function") {
200 // `JSON.stringify()` discards functions. We do too, unless a function is thrown directly.
201 return `[Function: ${value.name ?? "anonymous"}]`;
202 }
203
204 return value;
205}
206
207export function isErrorLike(value) {
208 return (

Callers 2

executeFnFunction · 0.90
processCallMethod · 0.90

Calls 1

destroyCircularFunction · 0.85

Tested by

no test coverage detected