Skip to main content

Error Handling

Every failure is an error you can catch broadly or match by category.

import { VideoSDKError, RoomNotFoundError } from "@videosdk/server-sdk";

try {
await client.rooms.get("does-not-exist");
} catch (err) {
if (err instanceof RoomNotFoundError) {
// room doesn't exist
} else if (err instanceof VideoSDKError) {
console.error(err.httpStatus, err.code, err.message, err.requestId);
}
}

Every error carries a message, HTTP status, machine-readable code, request id, the raw error body, and the method / path of the failing request. A zero or absent status means the error didn't come from a response, such as a network failure, timeout, or misconfiguration.

Error categories

Each category maps to an HTTP status. Node.js exposes an error subclass; Go exposes an Is* helper (and an Err* sentinel for errors.Is).

ConditionHTTPNode.jsGo
Bad request400ValidationErrorIsValidation
Unauthorized401AuthenticationErrorIsAuthentication
Forbidden403PermissionErrorIsPermission
Not found404 / 402RoomNotFoundErrorIsNotFound
Conflict409ResourceConflictErrorIsConflict
Rate limited429RateLimitErrorIsRateLimit
TimeoutTimeoutErrorIsTimeout
Bad configurationConfigurationErrorKindConfiguration
Webhook verificationWebhookVerificationErrorKindWebhookVerification

Retries

Transient failures are retried with exponential backoff (2 retries by default). The policy is conservative to avoid duplicating side effects:

  • 429 is retried for any request.
  • Network errors, timeouts, and 5xx are retried only for idempotent methods (GET, PUT, DELETE). A POST or PATCH may already have taken effect, so it is not retried.

Timeouts

Each request is bounded (default 30 seconds); exceeding it raises a timeout error.

const client = new VideoSDK({ apiKey, secret, timeoutMs: 60_000 });

Got a Question? Ask us on discord