pub fn get_error_hint(status_code: Option<u16>, error_code: i64, message: &str) -> Option<String> {
let msg_lower = message.to_lowercase();
if matches!(status_code, Some(401) | Some(403)) || error_code == 80001 {
return Some(
"Check your API key with `zilliz configure` or re-run `zilliz login`.".to_string(),
);
}
if msg_lower.contains("permissiondenied") || msg_lower.contains("permission deny") {
return Some(
"This may require a Dedicated cluster plan, or your API key may lack the required permissions.".to_string(),
);
}
if matches!(status_code, Some(429)) || msg_lower.contains("rate limit") {
return Some(
"Rate limit reached. Wait a moment and retry, or reduce request frequency.".to_string(),
);
}
if msg_lower.contains("timeout") || msg_lower.contains("timed out") {
return Some("Request timed out. Check your network connection and try again.".to_string());
}
if msg_lower.contains("connection") || msg_lower.contains("connect") {
return Some(
"Connection failed. Check your network and that the endpoint is reachable.".to_string(),
);
}
if matches!(status_code, Some(500..=599)) {
return Some(
"Server error. This is usually temporary -- retry in a few seconds.".to_string(),
);
}
None
}