scoped-error 0.1.3

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

//! `scoped_error` - Context-aware error handling.
//!
//! This library provides easy error context propagation without requiring
//! wrapper types at each layer. Context (message + location) is attached
//! directly to error types that implement [`WithContext`].
//!
//! # Quick Start
//!
//! For simple use cases, use [`scoped_error::Error`](crate::Error) with [`expect_error`]:
//!
//! ```
//! use scoped_error::{Error, expect_error};
//! # fn internal() -> Result<(), Error> { Ok(()) }
//!
//! fn do_work() -> Result<(), Error> {
//!     expect_error("Failed to do something", || {
//!         internal()?;
//!         Ok(())
//!     })
//! }
//! ```
//!
//! Use [`impl_context_error!`] to create custom context error types:
//!
//! ```
//! use scoped_error::{impl_context_error, expect_error};
//!
//! impl_context_error!(MyError);
//! # fn internal() -> Result<(), MyError> { Ok(()) }
//!
//! fn do_work() -> Result<(), MyError> {
//!     expect_error("Failed to do something", || {
//!         internal()?;
//!         Ok(())
//!     })
//! }
//! ```
//!
//! # Core Concepts
//!
//! - **Context propagation**: Attach context (message + source location) to errors
//! - **No wrapper types**: Context is stored directly in the error type
//! - **Automatic location tracking**: Uses `#[track_caller]` to capture call sites
//! - **Error reports**: Format full error chains with [`ErrorReport`]
mod conversion;
mod error;
mod ext;
mod macros;
mod many;
mod report;

pub use conversion::expect_error;
pub use conversion::expect_error_fn;
pub use error::Error;
pub use error::Frame;
pub use error::WithContext;
pub use ext::ErrorExt;
pub use many::Many;
pub use report::ErrorReport;