Convilyn developers

Errors

Every failure the SDK raises subclasses ConvilynError — catch the base class for a single safety net, or branch on code / statusCode for a specific failure mode.

Hierarchy

ClassExtendsMeaning
ConvilynErrorErrorBase — everything the SDK raises
AuthErrorConvilynErrorNo / malformed API key
APIErrorConvilynErrorHTTP 4xx / 5xx from the Convilyn API
RateLimitErrorAPIErrorRate limited
PlanRequiredErrorAPIErrorPlan does not include this action
QuotaExceededErrorAPIErrorQuota / cost cap reached
S3UploadErrorAPIErrorPresigned upload step returned non-success
RetryExhaustedErrorAPIErrorRetry policy ran out of attempts
JobFailedErrorConvilynErrorConversion job reached status failed
JobTimeoutErrorConvilynErrorConversion polling exceeded its timeout
GoalJobFailedErrorConvilynErrorGoal workflow reached status failed
GoalJobTimeoutErrorConvilynErrorGoal-workflow polling exceeded its timeout
WebSocketErrorConvilynErrorWorkflow event stream could not proceed

Handling

Branch on the specific subclass when you want a tailored remedy; fall back to ConvilynError for everything else.

import {
  ConvilynError,
  QuotaExceededError,
  RateLimitError,
  PlanRequiredError,
} from "@convilyn/sdk";
 
try {
  await client.goals.run({ goalText: "…", files: [file.fileId] });
} catch (err) {
  if (err instanceof QuotaExceededError) {
    console.error(
      `Need ${err.costCredits} credits, have ${err.balanceCredits}. Top up: ${err.topUpUrl}`,
    );
  } else if (err instanceof PlanRequiredError) {
    console.error(`Upgrade required: ${err.upgradeUrl}`);
  } else if (err instanceof RateLimitError) {
    console.error("Rate limited — back off and retry.");
  } else if (err instanceof ConvilynError) {
    console.error("SDK error:", err.message);
  } else {
    throw err;
  }
}

Where to go next