vtcode_commons/error_category/
recovery.rs1use super::*;
2
3impl ErrorCategory {
4 #[must_use]
7 pub fn recovery_suggestions(&self) -> Vec<Cow<'static, str>> {
8 match self {
9 ErrorCategory::Network => vec![
10 Cow::Borrowed("Check network connectivity"),
11 Cow::Borrowed("Retry the operation after a brief delay"),
12 Cow::Borrowed("Verify external service availability"),
13 ],
14 ErrorCategory::Timeout => vec![
15 Cow::Borrowed("Increase timeout values if appropriate"),
16 Cow::Borrowed("Break large operations into smaller chunks"),
17 Cow::Borrowed("Check system resources and performance"),
18 ],
19 ErrorCategory::RateLimit => vec![
20 Cow::Borrowed("Wait before retrying the request"),
21 Cow::Borrowed("Reduce request frequency"),
22 Cow::Borrowed("Check provider rate limit documentation"),
23 ],
24 ErrorCategory::ServiceUnavailable => vec![
25 Cow::Borrowed("The service is temporarily unavailable"),
26 Cow::Borrowed("Retry after a brief delay"),
27 Cow::Borrowed("Check service status page if available"),
28 ],
29 ErrorCategory::CircuitOpen => vec![
30 Cow::Borrowed("This tool has been temporarily disabled due to repeated failures"),
31 Cow::Borrowed("Wait for the circuit breaker cooldown period"),
32 Cow::Borrowed("Try an alternative approach"),
33 ],
34 ErrorCategory::Authentication => vec![
35 Cow::Borrowed("Verify your API key or credentials"),
36 Cow::Borrowed("Check that your account is active and has sufficient permissions"),
37 Cow::Borrowed("Ensure environment variables for API keys are set correctly"),
38 ],
39 ErrorCategory::InvalidParameters => vec![
40 Cow::Borrowed("Check parameter names and types against the tool schema"),
41 Cow::Borrowed("Ensure required parameters are provided"),
42 Cow::Borrowed("Verify parameter values are within acceptable ranges"),
43 ],
44 ErrorCategory::ToolNotFound => vec![
45 Cow::Borrowed("Verify the tool name is spelled correctly"),
46 Cow::Borrowed("Check if the tool is available in the current context"),
47 ],
48 ErrorCategory::ResourceNotFound => vec![
49 Cow::Borrowed("Verify file paths and resource locations"),
50 Cow::Borrowed("Check if files exist and are accessible"),
51 Cow::Borrowed("Use list_dir to explore available resources"),
52 ],
53 ErrorCategory::PermissionDenied => vec![
54 Cow::Borrowed("Check file permissions and access rights"),
55 Cow::Borrowed("Ensure workspace boundaries are respected"),
56 ],
57 ErrorCategory::PolicyViolation => vec![
58 Cow::Borrowed("Review workspace policies and restrictions"),
59 Cow::Borrowed("Use alternative tools that comply with policies"),
60 ],
61 ErrorCategory::PlanningPolicyViolation => vec![
62 Cow::Borrowed("This operation is not allowed in the Planning workflow with read-only permissions"),
63 Cow::Borrowed("Exit the Planning workflow to perform mutating operations"),
64 ],
65 ErrorCategory::SandboxFailure => vec![
66 Cow::Borrowed("The sandbox denied this operation"),
67 Cow::Borrowed("Check sandbox configuration and permissions"),
68 ],
69 ErrorCategory::ResourceExhausted => vec![
70 Cow::Borrowed("Check your account usage limits and billing status"),
71 Cow::Borrowed("Review resource consumption and optimize if possible"),
72 ],
73 ErrorCategory::Cancelled => vec![Cow::Borrowed("The operation was cancelled")],
74 ErrorCategory::ExecutionError => vec![
75 Cow::Borrowed("Review error details for specific issues"),
76 Cow::Borrowed("Check tool documentation for known limitations"),
77 ],
78 }
79 }
80}