MCPcopy Create free account
hub / github.com/continuedev/continue / createReplacer

Function createReplacer

extensions/cli/src/util/logger.ts:34–71  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

32
33// Simple replacer for JSON.stringify to handle common issues
34function createReplacer() {
35 const seen = new Set();
36
37 return (key: string, value: any) => {
38 // Handle circular references
39 if (typeof value === "object" && value !== null) {
40 if (seen.has(value)) {
41 return "[Circular]";
42 }
43 seen.add(value);
44 }
45
46 // Handle Error objects explicitly - extract useful properties
47 if (value instanceof Error) {
48 const errorObj: any = {
49 name: value.name,
50 message: value.message,
51 stack: value.stack,
52 };
53 if (value.cause) {
54 errorObj.cause = value.cause;
55 }
56 return errorObj;
57 }
58
59 // Handle functions
60 if (typeof value === "function") {
61 return "[Function]";
62 }
63
64 // Handle undefined (which JSON.stringify skips by default)
65 if (value === undefined) {
66 return "[undefined]";
67 }
68
69 return value;
70 };
71}
72
73// Custom format for log output
74const logFormat = printf(

Callers 1

logger.tsFile · 0.85

Calls 1

addMethod · 0.65

Tested by

no test coverage detected