Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 28 additions & 3 deletions crates/redisctl/src/commands/cloud/async_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ pub async fn wait_for_task(
}

// Check if task failed
if state == "failed" || state == "error" {
if state == "failed" || state == "error" || state == "processing-error" {
return Err(RedisCtlError::InvalidInput {
message: format!("Task {} failed", task_id),
});
Expand Down Expand Up @@ -195,15 +195,22 @@ fn get_task_state(task: &Value) -> String {
fn is_terminal_state(state: &str) -> bool {
matches!(
state.to_lowercase().as_str(),
"completed" | "complete" | "succeeded" | "success" | "failed" | "error" | "cancelled"
"completed"
| "complete"
| "succeeded"
| "success"
| "failed"
| "error"
| "cancelled"
| "processing-error"
)
}

/// Format task state for display
fn format_task_state(state: &str) -> String {
match state.to_lowercase().as_str() {
"completed" | "complete" | "succeeded" | "success" => format!("✓ {}", state),
"failed" | "error" => format!("✗ {}", state),
"failed" | "error" | "processing-error" => format!("✗ {}", state),
"cancelled" => format!("⊘ {}", state),
"processing" | "running" | "in_progress" => format!("⟳ {}", state),
_ => state.to_string(),
Expand Down Expand Up @@ -239,8 +246,26 @@ fn print_task_details(task: &Value) -> CliResult<()> {
println!("Updated: {}", updated);
}

// Handle error details - check both top-level and nested in response
if let Some(error) = task.get("error").or_else(|| task.get("errorMessage")) {
println!("Error: {}", error);
} else if let Some(response) = task.get("response")
&& let Some(error) = response.get("error")
{
// Handle nested error object
if let Some(error_type) = error.get("type") {
println!("Error Type: {}", error_type);
}
if let Some(error_status) = error.get("status") {
println!("Error Status: {}", error_status);
}
if let Some(error_description) = error.get("description") {
println!("Error Description: {}", error_description);
}
// If error is a simple string
if error.is_string() {
println!("Error: {}", error);
}
}

Ok(())
Expand Down