Skip to main content

Error Handling

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

import { VideoSDKError, RoomNotFoundError } from "@videosdk.live/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);
}
}

The error object

Every error carries these fields:

FieldTypeDescription
messagestringHuman-readable error message.
codestringMachine-readable error code.
httpStatusnumberHTTP status. Zero or absent when the error is not from a response (a network failure, timeout, or misconfiguration).
requestIdstringId of the failing request, useful for support.
detailsobjectRaw error response body.
methodstringHTTP method of the failing request.
pathstringPath of the failing request.

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), and Rust exposes an is_* predicate on Error.

ConditionHTTPNode.jsGoRust
Bad request400ValidationErrorIsValidationis_validation()
Unauthorized401AuthenticationErrorIsAuthenticationis_authentication()
Forbidden403PermissionErrorIsPermissionis_permission()
Not found404 / 402RoomNotFoundErrorIsNotFoundis_not_found()
Conflict409ResourceConflictErrorIsConflictis_conflict()
Rate limited429RateLimitErrorIsRateLimitis_rate_limit()
TimeoutTimeoutErrorIsTimeoutis_timeout()
Bad configurationConfigurationErrorErrConfigurationError::Configuration
Webhook verificationWebhookVerificationErrorErrWebhookVerification

In Go, configuration and webhook errors have no Is* helper — match them with errors.Is(err, videosdk.ErrConfiguration). In Rust, match the Error::Configuration variant directly; webhook verification is not yet available in the Rust SDK.

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