> ## Documentation Index
> Fetch the complete documentation index at: https://api-docs.sw4p.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Error Handling

> Handle errors gracefully

## Error Types

```typescript theme={null}
import { ApiError, AuthError, RateLimitError, NetworkError } from '@sw4p/bridge'
```

| Error            | Description       | Retryable |
| ---------------- | ----------------- | --------- |
| `AuthError`      | Invalid API key   | No        |
| `RateLimitError` | Too many requests | Yes       |
| `ApiError`       | General API error | Depends   |
| `NetworkError`   | Connection failed | Yes       |

## Handling Examples

```typescript theme={null}
try {
  const result = await bridge.transfer(params)
} catch (error) {
  if (error instanceof AuthError) {
    console.error('Invalid API key')
  }
  
  if (error instanceof RateLimitError) {
    await sleep(error.retryAfterMs)
    return retry()
  }
  
  if (error instanceof ApiError) {
    console.error(`API error: ${error.message}`)
  }
}
```

## Retry Strategy

The SDK includes automatic retry with exponential backoff:

```typescript theme={null}
const bridge = new Sw4pBridge({
  apiKey: 'sk_...',
  retry: {
    maxAttempts: 3,
    backoffMs: 1000
  }
})
```
