Skip to main content

Function: enrichAISDKError()

enrichAISDKError<T>(err): T

Defined in: packages/core/src/utils/format-error.ts:171

Enrich an Error in place with AI SDK diagnostics:

  • Attaches structured fields as err.diagnostics for clean UI rendering (read these instead of parsing .message).
  • Appends a (status=… url=… …) suffix to err.message for log lines.

Returns the same error object so consumers' instanceof checks (e.g. err instanceof APICallError) still work, and the original .stack still points at the provider call site.

Idempotent: calling twice on the same error is a no-op. Safe on non-Error values (returned unchanged).

Type Parameters

T

T

Parameters

err

T

Returns

T