JavaScript client
Errors
Handle typed client failures and safe retries.
Failed requests throw an Error. The error name contains the API error code when the response has the standard error shape; the message contains the safe server message.
try {
await client.assets.retrieve(assetId);
} catch (error) {
if (error instanceof Error && error.name === 'QUOTA_EXCEEDED') {
// Ask the user to upgrade or reduce the request.
}
throw error;
}Do not retry 400, 401, 403, or 404 responses without changing the request or credential. Use bounded exponential backoff for transient 5xx failures and preserve a request ID when the API provides one.