Error Handling with anyhow
Use anyhow::Result and the `?` operator for ergonomic errors.
Author:
chris
// Language: Rust
// Cargo.toml: anyhow = "1"
use anyhow::{Context, Result};
use std::fs;
fn main() -> Result<()> {
let path = "config.toml";
let body = fs::read_to_string(path)
.with_context(|| format!("reading {path}"))?;
println!("{body}");
Ok(())
}