pub enum ComposioError {
Show 41 variants
ApiError {
status: u16,
message: String,
code: Option<String>,
slug: Option<String>,
request_id: Option<String>,
suggested_fix: Option<String>,
errors: Option<Vec<ErrorDetail>>,
},
NetworkError(Error),
SerializationError(Error),
ValidationError(String),
ExecutionError(String),
InvalidInput(String),
ConfigError(String),
FileNotFound(String),
InvalidFile(String),
UploadFailed(String),
DownloadFailed(String),
FileTooLarge(String),
IoError(Error),
InvalidSchema(String),
NotFound(String),
ToolNotFound {
tool_slug: String,
},
ConnectedAccountNotFound {
account_id: String,
},
InvalidConnectedAccount {
reason: String,
},
MultipleConnectedAccounts {
user_id: String,
toolkit: String,
count: usize,
},
NoItemsFound(String),
ApiKeyNotProvided,
InvalidApiKey(String),
InvalidEnum {
value: String,
enum_name: String,
suggestion: String,
valid_values: Vec<String>,
},
InvalidParams(String),
ToolVersionRequired,
VersionSelectionError {
tool: String,
requested: String,
locked: String,
},
InvalidVersionString(String),
LockFileError(String),
InvalidLockFile(String),
TriggerError(String),
WebhookSignatureVerificationError(String),
WebhookPayloadError(String),
TriggerSubscriptionError(String),
InvalidTriggerFilters(String),
InvalidModifier(String),
ExecuteToolFnNotSet(String),
ErrorProcessingToolExecution(String),
Timeout(String),
ResponseTooLarge {
size: usize,
max_size: usize,
},
UsageError(String),
ToolkitError(String),
}Expand description
Main error type for the Composio SDK
Variants§
ApiError
API error returned from Composio backend
Fields
errors: Option<Vec<ErrorDetail>>Detailed field-level errors (optional)
NetworkError(Error)
Network error from HTTP client
SerializationError(Error)
JSON serialization error
ValidationError(String)
Validation error
ExecutionError(String)
Execution error
InvalidInput(String)
Invalid input provided by user
ConfigError(String)
Configuration error
FileNotFound(String)
File not found error
InvalidFile(String)
Invalid file error
UploadFailed(String)
File upload failed
DownloadFailed(String)
File download failed
FileTooLarge(String)
File too large error
IoError(Error)
I/O error
InvalidSchema(String)
Invalid schema error
NotFound(String)
Resource not found error
ToolNotFound
Tool not found error
ConnectedAccountNotFound
Connected account not found error
InvalidConnectedAccount
Invalid connected account error
MultipleConnectedAccounts
Multiple connected accounts found when one was expected
NoItemsFound(String)
No items found in collection
ApiKeyNotProvided
API key not provided error
InvalidApiKey(String)
Invalid API key error
InvalidEnum
Invalid enum value with suggestions
Fields
InvalidParams(String)
Invalid parameters provided
ToolVersionRequired
Toolkit version required error
VersionSelectionError
Version selection error
InvalidVersionString(String)
Invalid version string
LockFileError(String)
Lock file error
InvalidLockFile(String)
Invalid lock file
TriggerError(String)
Trigger error
WebhookSignatureVerificationError(String)
Webhook signature verification failed
WebhookPayloadError(String)
Invalid webhook payload
TriggerSubscriptionError(String)
Trigger subscription error
InvalidTriggerFilters(String)
Invalid trigger filters
InvalidModifier(String)
Invalid modifier error
ExecuteToolFnNotSet(String)
Tool execution function not set
ErrorProcessingToolExecution(String)
Error processing tool execution request
Timeout(String)
Request timeout error
ResponseTooLarge
Response too large error
UsageError(String)
SDK usage error
ToolkitError(String)
Toolkit error
Implementations§
Source§impl ComposioError
impl ComposioError
Sourcepub async fn from_response(response: Response) -> Self
pub async fn from_response(response: Response) -> Self
Create an ApiError from an HTTP response
This method attempts to parse the response body as an ErrorResponse. If parsing fails, it creates a generic ApiError with the status code.
Sourcepub fn invalid_enum(
value: impl Into<String>,
enum_name: impl Into<String>,
valid_values: Vec<String>,
) -> Self
pub fn invalid_enum( value: impl Into<String>, enum_name: impl Into<String>, valid_values: Vec<String>, ) -> Self
Create an InvalidEnum error with suggestions
Uses fuzzy matching to suggest the closest valid value. Similar to Python’s EnumStringNotFound with difflib.
§Example
use composio_sdk::error::ComposioError;
let valid_values = vec!["github".to_string(), "gmail".to_string(), "slack".to_string()];
let error = ComposioError::invalid_enum("gihub", "Toolkit", valid_values);
// Error message: "Invalid value 'gihub' for enum 'Toolkit'. Did you mean 'github'?"Sourcepub fn multiple_connected_accounts(
user_id: impl Into<String>,
toolkit: impl Into<String>,
count: usize,
) -> Self
pub fn multiple_connected_accounts( user_id: impl Into<String>, toolkit: impl Into<String>, count: usize, ) -> Self
Create a MultipleConnectedAccounts error
Sourcepub fn version_selection_error(
tool: impl Into<String>,
requested: impl Into<String>,
locked: impl Into<String>,
) -> Self
pub fn version_selection_error( tool: impl Into<String>, requested: impl Into<String>, locked: impl Into<String>, ) -> Self
Create a VersionSelectionError
Sourcepub fn response_too_large(size: usize, max_size: usize) -> Self
pub fn response_too_large(size: usize, max_size: usize) -> Self
Create a ResponseTooLarge error
Sourcepub fn tool_not_found(tool_slug: impl Into<String>) -> Self
pub fn tool_not_found(tool_slug: impl Into<String>) -> Self
Create a ToolNotFound error
Sourcepub fn connected_account_not_found(account_id: impl Into<String>) -> Self
pub fn connected_account_not_found(account_id: impl Into<String>) -> Self
Create a ConnectedAccountNotFound error
Sourcepub fn format_validation_error(&self) -> String
pub fn format_validation_error(&self) -> String
Format validation error with detailed field information
Provides a developer-friendly error message highlighting:
- Missing required fields
- Invalid field values
- Field-specific error messages
This is particularly useful for debugging API validation errors and improving monitoring/logging output.
§Returns
A formatted string with:
- Base error message
- List of missing fields (if any)
- Detailed field-level errors with parameter names
§Example
use composio_sdk::error::{ComposioError, ErrorDetail};
let error = ComposioError::ApiError {
status: 400,
message: "Validation failed".to_string(),
code: Some("VALIDATION_ERROR".to_string()),
slug: None,
request_id: Some("req_123".to_string()),
suggested_fix: None,
errors: Some(vec![
ErrorDetail {
field: Some("user_id".to_string()),
message: "Field required".to_string(),
},
ErrorDetail {
field: Some("toolkit".to_string()),
message: "Invalid toolkit name".to_string(),
}
]),
};
let formatted = error.format_validation_error();
println!("{}", formatted);
// Output:
// Validation failed
// - Following fields are missing: ["user_id"]
// - Invalid toolkit name on parameter `toolkit`Sourcepub fn is_retryable(&self) -> bool
pub fn is_retryable(&self) -> bool
Check if this error should be retried
Returns true for transient errors that may succeed on retry:
- 429 (Rate Limited)
- 500 (Internal Server Error)
- 502 (Bad Gateway)
- 503 (Service Unavailable)
- 504 (Gateway Timeout)
- Network errors
- Timeout errors
Returns false for client errors (4xx except 429) that won’t succeed on retry.
Trait Implementations§
Source§impl Debug for ComposioError
impl Debug for ComposioError
Source§impl Display for ComposioError
impl Display for ComposioError
Source§impl Error for ComposioError
impl Error for ComposioError
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()