Skip to content
EmitKitDocs
Esc
↑↓navigate↵open⌘Jpreview

Error handling

Handle SDK validation, rate-limit, and API errors without exposing credentials.

import { EmitKitError, RateLimitError, ValidationError } from '@emitkit/js';

try {
  await client.events.create({ channelName: 'general', title: 'Deployed' });
} catch (error) {
  if (error instanceof RateLimitError) {
    console.error(`Retry in ${error.rateLimit.resetIn}ms`);
  } else if (error instanceof ValidationError) {
    console.error(error.validationErrors);
  } else if (error instanceof EmitKitError) {
    console.error(error.statusCode, error.requestId);
  }
}

Record the request ID when asking for support. Never record the API key or the complete Authorization header.

Was this page helpful?