Error Handling
Every failure is an error you can catch broadly or match by category.
- Node.js
- Go
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);
}
}
_, err := client.Rooms.Get(ctx, "does-not-exist")
switch {
case videosdk.IsNotFound(err):
// room doesn't exist
case videosdk.IsRateLimit(err):
// back off
}
var apiErr *videosdk.Error
if errors.As(err, &apiErr) {
log.Println(apiErr.HTTPStatus, apiErr.Code, apiErr.Message, apiErr.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).
| Condition | HTTP | Node.js | Go |
|---|---|---|---|
| Bad request | 400 | ValidationError | IsValidation |
| Unauthorized | 401 | AuthenticationError | IsAuthentication |
| Forbidden | 403 | PermissionError | IsPermission |
| Not found | 404 / 402 | RoomNotFoundError | IsNotFound |
| Conflict | 409 | ResourceConflictError | IsConflict |
| Rate limited | 429 | RateLimitError | IsRateLimit |
| Timeout | TimeoutError | IsTimeout | |
| Bad configuration | ConfigurationError | KindConfiguration | |
| Webhook verification | WebhookVerificationError | KindWebhookVerification |
Retries
Transient failures are retried with exponential backoff (2 retries by default). The policy is conservative to avoid duplicating side effects:
429is retried for any request.- Network errors, timeouts, and
5xxare retried only for idempotent methods (GET,PUT,DELETE). APOSTorPATCHmay already have taken effect, so it is not retried.
Timeouts
Each request is bounded (default 30 seconds); exceeding it raises a timeout error.
- Node.js
- Go
const client = new VideoSDK({ apiKey, secret, timeoutMs: 60_000 });
client, err := videosdk.NewClient(
videosdk.WithAPIKey(apiKey),
videosdk.WithSecret(secret),
videosdk.WithRequestTimeout(60*time.Second),
)
Got a Question? Ask us on discord

