Expand description
§Error Types for RepoLens
This module defines custom error types using thiserror for better error handling
and more descriptive error messages throughout the application.
§Error Hierarchy
The main error type is RepoLensError, which wraps more specific error types:
ScanError- Errors during repository scanningConfigError- Configuration loading and parsing errorsProviderError- External service errors (GitHub API)ActionError- Remediation action execution errorsRuleError- Rule evaluation errorsCacheError- Caching operation errors
§Examples
§Handling Errors
use repolens::{config::Config, RepoLensError};
fn load_config() -> Result<Config, RepoLensError> {
Config::load_or_default()
}
match load_config() {
Ok(config) => println!("Loaded config with preset: {}", config.preset),
Err(e) => {
eprintln!("{}", e.display_formatted());
if let Some(suggestion) = e.suggestion() {
eprintln!("Hint: {}", suggestion);
}
}
}§Error Suggestions
Many errors include helpful suggestions for resolution:
use repolens::error::{RepoLensError, ConfigError};
let err = RepoLensError::Config(ConfigError::ConfigNotFound {
path: ".repolens.toml".to_string(),
});
// Get a suggestion for how to fix the error
if let Some(suggestion) = err.suggestion() {
assert!(suggestion.contains("repolens init"));
}Enums§
- Action
Error - Errors that occur during action execution
- Cache
Error - Errors that occur during cache operations
- Config
Error - Errors that occur during configuration loading and parsing
- Provider
Error - Errors that occur when interacting with external providers (GitHub API, etc.)
- Repo
Lens Error - Main error type for RepoLens
- Rule
Error - Errors that occur during rule execution
- Scan
Error - Errors that occur during repository scanning
Constants§
- VALID_
PRESETS - Valid preset names for error messages