scoped-error 0.1.5

Structured error handling with semantic context trees.
Documentation
// Copyright (C) 2026 Kan-Ru Chen <kanru@kanru.info>
//
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

use std::io;

use scoped_error::{Context, Error, expect_error};

fn parse_url(url: &str) -> io::Result<()> {
    let _ = url;
    Err(io::Error::other("invalid URL format"))
}

fn connect(url: &str) -> Result<String, Error> {
    parse_url(url).context("failed to parse url")?;
    Ok("hello".to_string())
}

fn main() -> Result<(), Error> {
    expect_error("This program will error", || {
        connect("")?;
        Ok(())
    })
}