Skip to main content

map_cloud_client_error

Function map_cloud_client_error 

Source
pub fn map_cloud_client_error(
    cloud_error: Error,
    operation_context: String,
    resource_id: Option<String>,
) -> Error
Expand description

Maps an alien_client_core::Error to an appropriate alien_bindings::Error.

Important error types (like resource not found, access denied, etc.) are mapped to their corresponding variants in alien-bindings while preserving the operation context. Less important errors are wrapped in CloudPlatformError.

§Arguments

  • cloud_error - The error from cloud client crates
  • operation_context - Description of the operation that failed (e.g., “Failed to get ECR repository details”)
  • resource_id - Optional resource ID for fallback error context

§Example

use alien_bindings::error::map_cloud_client_error;

async fn example() {
    // This would be an actual cloud client operation
    let result = some_cloud_operation().await
        .map_err(|e| map_cloud_client_error(e, "Failed to get ECR repository details".to_string(), Some("my-repo".to_string())));
}

async fn some_cloud_operation() -> Result<(), alien_client_core::Error> {
    // Mock implementation
    Ok(())
}