Skip to content

redactErrorForLogging

function redactErrorForLogging(error: unknown): Record<string, unknown>;

Defined in: src/logging/redaction.ts:119

Converts an arbitrary thrown value into a JSON-safe, secret-free record.

Structured SDK errors are serialized through their toJSON() (which already redacts details); plain errors contribute name/message/stack-free context; other values are stringified. Use this at every internal log site that records a caught error.

ParameterTypeDescription
errorunknownCaught value of unknown shape.

Record<string, unknown>

A redacted, JSON-safe object describing the error.