Module error

Module error 

Source
Expand description

Error types and error handling utilities for package tools operations.

What: Provides a comprehensive error hierarchy for all package tools operations, including detailed error contexts, error recovery strategies, and result type aliases.

How: This module defines domain-specific error types for each major operation area (changesets, versioning, dependencies, upgrades, changelog, audit), with rich context information and support for error chaining and recovery.

Why: To provide clear, actionable error messages that help users understand what went wrong and how to fix it, while enabling robust error handling and recovery in automated workflows.

§Features

  • Hierarchical Errors: Structured error types organized by operation domain
  • Rich Context: Detailed error information including paths, operations, and reasons
  • Error Chaining: Support for nested errors to preserve error context
  • Error Conversion: Automatic conversion from standard library and dependency errors
  • Display Formatting: Human-readable error messages
  • Debug Information: Detailed debug output for troubleshooting

§Error Categories

§ConfigError

Errors related to configuration loading, parsing, and validation.

§VersionError

Errors related to version resolution, propagation, and application.

§ChangesetError

Errors related to changeset operations (create, load, update, archive).

§ChangesError

Errors related to changes analysis and file-to-package mapping.

§ChangelogError

Errors related to changelog generation and parsing.

§UpgradeError

Errors related to dependency upgrade detection and application.

§AuditError

Errors related to audits and health checks.

§Example

use sublime_pkg_tools::error::{Error, Result};

fn process_package() -> Result<()> {
    // Operation that might fail
    Ok(())
}

match process_package() {
    Ok(_) => println!("Success!"),
    Err(e) => eprintln!("Error: {}", e),
}

§Domain-Specific Results

Each error module provides a result type alias for convenience:

use sublime_pkg_tools::error::{
    ConfigResult, VersionResult, ChangesetResult,
    ChangesResult, ChangelogResult, UpgradeResult, AuditResult
};

fn load_config() -> ConfigResult<String> {
    Ok("config".to_string())
}

fn resolve_version() -> VersionResult<String> {
    Ok("1.0.0".to_string())
}

§Error Conversion

Errors from internal crates (sublime_standard_tools, sublime_git_tools) are automatically converted to the appropriate domain error:

use sublime_pkg_tools::error::{Error, Result};
use sublime_standard_tools::filesystem::FileSystemManager;

async fn read_package_json() -> Result<String> {
    let fs = FileSystemManager::new();
    // FileSystemError automatically converts to Error::FileSystem
    let content = fs.read_file_string("package.json").await?;
    Ok(content)
}

Re-exports§

pub use self::audit::AuditError;
pub use self::audit::AuditResult;
pub use self::changelog::ChangelogError;
pub use self::changelog::ChangelogResult;
pub use self::changes::ChangesError;
pub use self::changes::ChangesResult;
pub use self::changeset::ChangesetError;
pub use self::changeset::ChangesetResult;
pub use self::config::ConfigError;
pub use self::config::ConfigResult;
pub use self::upgrade::UpgradeError;
pub use self::upgrade::UpgradeResult;
pub use self::version::VersionError;
pub use self::version::VersionResult;
pub use self::context::ErrorContext;
pub use self::context::WithContext;
pub use self::recovery::ErrorRecoveryManager;
pub use self::recovery::LogLevel;
pub use self::recovery::RecoveryResult;
pub use self::recovery::RecoveryStats;
pub use self::recovery::RecoveryStrategy;

Modules§

audit
Audit error types for package tools.
changelog
Changelog error types for package tools.
changes
Changes analysis error types for package tools.
changeset
Changeset error types for package tools.
config
Configuration error types for package tools.
context
Error context utilities for adding contextual information to errors.
recovery
Error recovery strategies and management for package tools operations.
upgrade
Upgrade error types for package tools.
version
Version error types for package tools.

Enums§

Error
Main error type for package tools operations.

Type Aliases§

Result
Result type alias for package tools operations.