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

# Error Codes

> API error codes and handling

## Error Format

```json theme={null}
{
  "error": {
    "code": "error_code",
    "message": "Human-readable error message",
    "details": {}
  }
}
```

## Common Error Codes

| Code                    | Status | Description                      |
| ----------------------- | ------ | -------------------------------- |
| `unauthorized`          | 401    | Invalid or missing API key       |
| `session_not_found`     | 404    | Session doesn't exist or expired |
| `rate_limit_exceeded`   | 429    | Too many requests                |
| `execution_timeout`     | 408    | Code execution timed out         |
| `memory_limit_exceeded` | 507    | Memory limit exceeded            |
| `disk_full`             | 507    | Disk space limit exceeded        |
| `invalid_request`       | 400    | Invalid request parameters       |

## Handling Errors

```typescript theme={null}
try {
  const result = await client.execute({ ... });
} catch (error) {
  if (error instanceof BuntimeError) {
    switch (error.code) {
      case 'session_not_found':
        // Handle expired session
        break;
      case 'rate_limit_exceeded':
        // Wait and retry
        await new Promise(r => setTimeout(r, error.retryAfter * 1000));
        break;
      default:
        console.error('Error:', error.message);
    }
  }
}
```
