Skip to main content

Module error

Module error 

Source
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:

§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§

ActionError
Errors that occur during action execution
CacheError
Errors that occur during cache operations
ConfigError
Errors that occur during configuration loading and parsing
ProviderError
Errors that occur when interacting with external providers (GitHub API, etc.)
RepoLensError
Main error type for RepoLens
RuleError
Errors that occur during rule execution
ScanError
Errors that occur during repository scanning

Constants§

VALID_PRESETS
Valid preset names for error messages