TypeScript SDK errors

A non-success response rejects with a generated error object rather than resolving to undefined, so a rejected call cannot be mistaken for a successful one.

try {
  await management.management.issuers.byIssuerId(issuerId).patch(update, {
    queryParameters: { apiVersion: API_VERSION },
    headers: { 'If-Match': etag },
  });
} catch (caught: any) {
  const code = caught?.error?.code;
  const requestId = caught?.error?.innerError?.requestId;

  console.warn('DiligenceID rejected the update', { code, requestId });

  if (code === 'precondition_failed') {
    // Re-read, re-apply, retry.
  }
}

Branch on code

Not on message. code is the stable contract; message is for humans and may be reworded.

Log the request id

error.innerError.requestId is the server's identifier for the failed request, also on the response as x-ms-request-id. Log it on every failure.

What to retry

Code / status Retry
429, 5xx Yes, with backoff
precondition_failed Yes, after re-reading
400, 401, 403, 404, 409 No

A retry of a mutating call needs the same Idempotency-Key as the original attempt. A fresh one defeats the mechanism.

Edit this page on GitHub