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 scoped_error::{Error, bail, expect_error};

fn connect(url: &str) -> Result<String, Error> {
    expect_error("Failed to connect to target", || {
        if !url.is_empty() {
            return Ok("connected".to_string());
        }
        bail!("invalid URL [{}]", url);
    })
}

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