MCPcopy Create free account
hub / github.com/agent-tower/core / normalizeError

Function normalizeError

packages/server/src/utils/error-log.ts:94–105  ·  view source on GitHub ↗
(error: unknown)

Source from the content-addressed store, hash-verified

92}
93
94function normalizeError(error: unknown): Record<string, unknown> | null {
95 if (error == null) return null;
96 if (error instanceof Error) {
97 return sanitizeValue({
98 name: error.name,
99 message: error.message,
100 stack: error.stack,
101 code: (error as { code?: unknown }).code,
102 }) as Record<string, unknown>;
103 }
104 return sanitizeValue({ message: String(error) }) as Record<string, unknown>;
105}
106
107function sanitizeValue(value: unknown, key = '', depth = 0): unknown {
108 if (key && SENSITIVE_KEY_PATTERN.test(key)) {

Callers 2

formatErrorLogEntryFunction · 0.85
sanitizeValueFunction · 0.85

Calls 1

sanitizeValueFunction · 0.85

Tested by

no test coverage detected