Skip to main content

io_error_with_path

Function io_error_with_path 

Source
pub fn io_error_with_path(
    err: Error,
    path: &Path,
    action: &str,
) -> FoundationError
Expand description

Helper to wrap IO errors with path context.

Creates a new IO error that preserves the original error kind but adds descriptive context including the action being performed and the file path.

ยงExample

use rh_foundation::error::io_error_with_path;
use std::path::Path;

fn example() -> rh_foundation::Result<()> {
    let path = Path::new("config.json");
    std::fs::read_to_string(path).map_err(|e| {
        io_error_with_path(e, path, "read config from")
    })?;
    Ok(())
}