DuckVizBeta
SDK

Errors

Typed error classes for authentication, quota, rate limiting, and transport failures.

Every SDK call throws a typed error on failure. Handle them in a typed catch to react appropriately.

import {
  DuckvizError,
  DuckvizAuthError,
  DuckvizQuotaExceededError,
  DuckvizRateLimitError,
  DuckvizServerError,
  DuckvizNetworkError,
} from "@duckviz/sdk";

try {
  await widgetFlow.invoke(input);
} catch (e) {
  if (e instanceof DuckvizAuthError) {
    console.error("Check your API token");
  } else if (e instanceof DuckvizQuotaExceededError) {
    console.error("Buy more credits");
  } else if (e instanceof DuckvizRateLimitError) {
    console.error("Slow down, retry after:", e.retryAfter);
  } else if (e instanceof DuckvizServerError) {
    console.error("Server-side failure, try again later");
  } else if (e instanceof DuckvizNetworkError) {
    console.error("Network failure — no response received");
  }
}

Error class reference

ClassStatusWhen it fires
DuckvizAuthError401Token missing, expired, or revoked.
DuckvizQuotaExceededError402No credits remaining.
DuckvizRateLimitError429Too many requests per window. Includes retryAfter (seconds).
DuckvizServerError5xxServer-side error. Automatically retried up to maxRetries.
DuckvizNetworkErrorTransport failure with no HTTP response (DNS, TCP reset, timeout).
DuckvizErrorBase class. All of the above extend it.

Retry semantics

DuckvizServerError and DuckvizNetworkError are retried automatically with exponential backoff, capped at maxRetries (default 3). DuckvizAuthError, DuckvizQuotaExceededError, and DuckvizRateLimitError are not retried — they're treated as definitive.

Override retries per class:

const sdk = new DuckvizWidgetFlow({ token, maxRetries: 0 });