Error Handling
Learn how to handle errors gracefully when working with TraceMem's Agent MCP server.
Overview
Proper error handling ensures your agents can recover from failures and provide meaningful feedback.
Error Types
[Content to be filled - authentication errors, permission errors, rate limits, etc.]
Error Handling Patterns
Handle errors gracefully:
python
try:
result = client.call_tool("decision_read", {...})
except Exception as e:
if "401" in str(e) or "Unauthorized" in str(e):
print("Invalid API key")
elif "403" in str(e) or "Forbidden" in str(e):
print("Permission denied")
elif "429" in str(e):
print("Rate limited - retry later")
else:
print(f"Error: {e}")
Retry Strategies
[Content to be filled]
Common Error Scenarios
Authentication Errors
python
if "401" in str(e) or "Unauthorized" in str(e):
print("Invalid API key")
# Handle: Check API key, re-authenticate
Permission Errors
python
elif "403" in str(e) or "Forbidden" in str(e):
print("Permission denied")
# Handle: Check agent permissions, data product access
Rate Limiting
python
elif "429" in str(e):
print("Rate limited - retry later")
# Handle: Implement exponential backoff, retry after delay
Policy Denials
[Content to be filled]
Best Practices
[Content to be filled]