pub fn user_friendly_error(error: Error) -> ErrorContextExpand description
Convert any error to a user-friendly ErrorContext with actionable suggestions
This function is the main entry point for converting arbitrary errors into user-friendly error messages for CLI display. It recognizes common error types and provides appropriate context and suggestions.
§Error Recognition
The function recognizes and provides specific handling for:
AgpmErrorvariants with tailored suggestionsstd::io::Errorwith filesystem-specific guidancetoml::de::Errorwith TOML syntax help- Generic errors with basic context
§Examples
§Converting AGPM Errors
use agpm_cli::core::{AgpmError, user_friendly_error};
let error = AgpmError::GitNotFound;
let anyhow_error = anyhow::Error::from(error);
let context = user_friendly_error(anyhow_error);
context.display(); // Shows git installation suggestions§Converting IO Errors
use agpm_cli::core::user_friendly_error;
use std::io::{Error, ErrorKind};
let io_error = Error::new(ErrorKind::PermissionDenied, "access denied");
let anyhow_error = anyhow::Error::from(io_error);
let context = user_friendly_error(anyhow_error);
context.display(); // Shows permission-related suggestions§Converting Generic Errors
use agpm_cli::core::user_friendly_error;
let error = anyhow::anyhow!("Something went wrong");
let context = user_friendly_error(error);
context.display(); // Shows the error with generic formatting