Documentation
¶
Overview ¶
Package clierrors provides utilities for formatting error messages in the CLI. It helps create consistent, user-friendly error output with context and suggestions.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FormatError ¶
FormatError wraps an error with operation context for better CLI output.
Example:
err := fmt.Errorf("connection refused")
formatted := FormatError("connecting to server", err)
// Output: "Error during connecting to server: connection refused"
func FormatMultiError ¶
FormatMultiError combines multiple errors into a single formatted error.
Example:
errors := []error{
fmt.Errorf("file not found: rule1.yaml"),
fmt.Errorf("file not found: rule2.yaml"),
}
err := FormatMultiError("rule validation", errors)
// Output: "Multiple errors during rule validation:
// - file not found: rule1.yaml
// - file not found: rule2.yaml"
func FormatScannerError ¶
FormatScannerError adds scanner context to an error message.
Example:
err := fmt.Errorf("executable not found in PATH")
formatted := FormatScannerError("semgrep", err)
// Output: "Scanner 'semgrep' error: executable not found in PATH"
func FormatValidationError ¶
FormatValidationError creates a validation error with a suggestion.
Example:
err := FormatValidationError("--rules", "no rule files specified", "use --rules <file> or --rules-dir <dir>")
// Output: "Validation error for --rules: no rule files specified. Suggestion: use --rules <file> or --rules-dir <dir>"
func WrapWithSuggestion ¶
WrapWithSuggestion wraps an error with a helpful suggestion.
Example:
err := fmt.Errorf("semgrep not found in PATH")
wrapped := WrapWithSuggestion(err, "install semgrep: pip install semgrep")
// Output: "semgrep not found in PATH (suggestion: install semgrep: pip install semgrep)"
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.