Error Handling
Error Types
from amigo_sdk.errors import (
AmigoError, # Base error class
AuthenticationError, # Invalid credentials
NotFoundError, # Resource not found
BadRequestError, # Invalid request
ValidationError, # Request validation failed
ConflictError, # Resource conflict
NetworkError, # Network/connection issues
)import { errors } from '@amigo-ai/sdk'
// Available error types:
errors.AmigoError // Base error class
errors.AuthenticationError // Invalid credentials
errors.NotFoundError // Resource not found
errors.BadRequestError // Invalid request
errors.ValidationError // Request validation failed
errors.ConflictError // Resource conflict
errors.NetworkError // Network/connection issuesBasic Error Handling
from amigo_sdk import AmigoClient
from amigo_sdk.errors import (
AuthenticationError,
NotFoundError,
BadRequestError,
ValidationError,
ConflictError,
NetworkError,
AmigoError
)
def handle_errors_example():
try:
with AmigoClient(
api_key="your-api-key",
api_key_id="your-api-key-id",
user_id="your-user-id",
organization_id="your-org-id"
) as client:
# Your API calls here
org = client.organization.get()
print(f"Organization: {org.name}")
except AuthenticationError as e:
print(f"Authentication failed: {e}")
# Handle invalid credentials - check API keys
except NotFoundError as e:
print(f"Resource not found: {e}")
# Handle missing resources - check IDs
except BadRequestError as e:
print(f"Bad request: {e}")
# Handle invalid request format
except ValidationError as e:
print(f"Validation failed: {e}")
# Handle request validation errors
except ConflictError as e:
print(f"Conflict: {e}")
# Handle resource conflicts (often recoverable)
except NetworkError as e:
print(f"Network error: {e}")
# Handle connection issues - SDKs handle retries automatically
except AmigoError as e:
print(f"Amigo API error: {e}")
# Handle any other Amigo-specific errors
except Exception as e:
print(f"Unexpected error: {e}")
# Handle unexpected errorsStream Error Handling
Built-in Retry Logic
Error Type
Retry Strategy
Retry Flow Diagram
Best Practices
Next Steps
Last updated
Was this helpful?

