Overview
Proper error handling is crucial for building reliable applications with Composio. This guide covers the different types of errors, how to handle them, and best practices for error recovery.Error Types
Composio SDK has two main categories of errors:- SDK-Level Errors: Thrown as exceptions that you catch with try-catch
- Tool-Level Errors: Returned in the execution response’s
errorfield
SDK-Level Errors
These errors are thrown when there’s an issue with SDK operations (validation, API communication, etc.).Base Error Class
All Composio errors extend theComposioError class:
Error Properties
ComposioError provides helpful properties:name: Error type name (e.g., ‘ComposioToolNotFoundError’)message: Human-readable error messagecode: Error code for categorization (e.g., ‘TS-SDK::TOOL_NOT_FOUND’)statusCode: HTTP status code (when applicable)cause: The underlying error that caused this errorpossibleFixes: Array of suggested solutionsmeta: Additional metadata about the error
Common SDK Errors
Tool Not Found Error
Connected Account Not Found Error
Validation Error
Tool Version Required Error
Multiple Connected Accounts Error
Invalid Modifier Error
Tool-Level Errors
When a tool executes but fails, the error is returned in the response object:Error Response Structure
Comprehensive Error Handling
Basic Pattern
Advanced Error Handling with Retry Logic
Error Logging and Monitoring
Error Recovery Strategies
Handle Authentication Errors
Handle Rate Limiting
Handle Token Refresh
Pretty Printing Errors
ComposioError has a built-in pretty print method:Custom Error Display
Connection Request Errors
Best Practices
Always Check Both Levels
Check for SDK exceptions AND tool-level errors in responses.
Use Type Guards
Use
instanceof checks to handle specific error types appropriately.Log Context
Include context (toolSlug, userId, etc.) when logging errors.
Implement Retry Logic
Add retry logic for transient errors like rate limits and timeouts.
Error Handling Checklist
- Wrap tool execution in try-catch blocks
- Check
result.successfulbefore usingresult.data - Handle specific error types (ValidationError, ToolNotFoundError, etc.)
- Implement retry logic for transient errors
- Log errors with sufficient context for debugging
- Use
result.logIdto trace tool execution in Composio dashboard - Provide user-friendly error messages
- Implement fallback behavior when tools fail
- Monitor error rates and types in production
- Use pretty printing during development
Next Steps
Tool Execution
Learn about tool execution patterns
Authentication Flows
Handle authentication-related errors
Modifiers
Use modifiers for custom error handling
Environment Variables
Configure error behavior via environment