Skip to content

Function: isIdempotencyControlSignal()

ts
function isIdempotencyControlSignal(
  err
): err is NosanaApiError & { code: IdempotencyCode };

Narrows a caught value to a coded idempotency control signal — a 409 whose body carries a known IdempotencyCode (IN_PROGRESS → retry the same key, EXPIRED → fresh key, PAYLOAD_MISMATCH → fatal).

The membership check is what makes the code: IdempotencyCode narrowing sound: NosanaApiError.code is a free-form server code, so this returns false for a code-less error, a network failure, and any non-idempotency code — all of which the caller should treat as ordinary rejections. An exhaustive switch over the narrowed code is therefore genuinely exhaustive.

Parameters

ParameterType
errunknown

Returns

err is NosanaApiError & { code: IdempotencyCode }