MCPcopy Index your code
hub / github.com/callstack/agent-device / normalizeError

Function normalizeError

src/kernel/errors.ts:80–105  ·  view source on GitHub ↗
(
  err: unknown,
  context: { diagnosticId?: string; logPath?: string } = {},
)

Source from the content-addressed store, hash-verified

78}
79
80export function normalizeError(
81 err: unknown,
82 context: { diagnosticId?: string; logPath?: string } = {},
83): NormalizedError {
84 const appErr = asAppError(err);
85 const details = appErr.details ? redactDiagnosticData(appErr.details) : undefined;
86 const detailHint = details && typeof details.hint === 'string' ? details.hint : undefined;
87 const diagnosticId =
88 (details && typeof details.diagnosticId === 'string' ? details.diagnosticId : undefined) ??
89 context.diagnosticId;
90 const logPath =
91 (details && typeof details.logPath === 'string' ? details.logPath : undefined) ??
92 context.logPath;
93 const hint = detailHint ?? defaultHintForCode(appErr.code);
94 const cleanDetails = stripDiagnosticMeta(details);
95 const message = maybeEnrichCommandFailedMessage(appErr.code, appErr.message, details);
96
97 return {
98 code: appErr.code,
99 message,
100 hint,
101 diagnosticId,
102 logPath,
103 details: cleanDetails,
104 };
105}
106
107function maybeEnrichCommandFailedMessage(
108 code: string,

Callers 15

runCliFunction · 0.90
cli.tsFile · 0.90
sendUnauthorizedFunction · 0.90
sendProxyErrorFunction · 0.90
printHumanErrorFunction · 0.90
png-worker.tsFile · 0.90
errors.test.tsFile · 0.90
handleArtifactDownloadFunction · 0.90
handleArtifactInventoryFunction · 0.90
finalizeDaemonResponseFunction · 0.90

Calls 5

redactDiagnosticDataFunction · 0.90
asAppErrorFunction · 0.85
defaultHintForCodeFunction · 0.85
stripDiagnosticMetaFunction · 0.85

Tested by

no test coverage detected