> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.withpaygent.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.withpaygent.com/_mcp/server.

# Error Handling

Proper error handling ensures your application remains stable even if usage tracking fails.

## The Golden Rule

> **Never let usage tracking failures break your main application!**
>
> If tracking fails, log the error and continue. Your users care about your app working, not whether usage was tracked.

---

## Python

```python
try:
    client.send_usage(agent, customer, indicator, usage_data)
except Exception as e:
    # Log but don't raise - app continues
    logging.warning(f"Failed to track usage: {e}")
```

## Node.js / TypeScript

```typescript
try {
  await paygentClient.sendUsage(agent, customer, indicator, usageData);
} catch (error) {
  // Log but don't throw - app continues normally
  console.error('Failed to track usage:', error);
}
```

## Go

```go
err := client.SendUsage(agent, customer, indicator, usageData)
if err != nil {
    // Log but don't return error - app continues
    log.Printf("warning: failed to track usage: %v", err)
}
```

> **Warning**
>
> **Production Best Practices:**
>
> * Use try-catch/error handling around all tracking calls
> * Log errors for debugging but don't crash the app
> * Consider adding retry logic for transient failures
> * Monitor error rates in your logging system