Skip to main content

Module error

Module error 

Source
Expand description

Error types for AION v2

This module defines the error types used throughout AION v2. Following Tiger Style, all errors are explicit, provide actionable messages, and implement std::error::Error.

§Error Categories

Errors are organized into logical categories for clarity:

  • I/O Errors - File system operations
  • Cryptographic Errors - Signature and encryption failures
  • Format Errors - File parsing and validation
  • Version Errors - Version chain and history issues
  • Key Management Errors - Keyring and key storage
  • Validation Errors - Input validation failures
  • Operational Errors - Runtime operation failures

§Usage Example

use aion_context::{AionError, Result};
use std::path::PathBuf;

fn load_file(path: &str) -> Result<Vec<u8>> {
    std::fs::read(path).map_err(|e| AionError::FileReadError {
        path: PathBuf::from(path),
        source: e,
    })
}

// Errors provide contextual information
match load_file("nonexistent.aion") {
    Ok(data) => println!("Loaded {} bytes", data.len()),
    Err(e) => eprintln!("Error: {e}"),
}

§Error Handling Best Practices

  1. Always use ? operator for error propagation
  2. Add context to errors when re-wrapping
  3. Match on error types for specific handling
  4. Display errors to users with helpful messages
use aion_context::Result;

fn process_file() -> Result<()> {
    let data = load_file("file.aion")?;  // ✓ Propagate errors
    verify_signatures(&data)?;            // ✓ Chain operations
    Ok(())
}

Enums§

AionError
Top-level error type for AION v2

Type Aliases§

Result
Result type alias for AION operations