---
title: Error handling
description: Handle SDK validation, rate-limit, and API errors without exposing credentials.
sidebar:
  order: 4
---

```typescript
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.
