1
1
Fork
You've already forked scoped-error
0
Structured error handling with semantic context trees. Zero proc-macros. Zero backtrace overhead.
  • Rust 100%
2026年06月23日 21:59:07 +09:00
examples context: implement anyhow style Context trait 2026年06月23日 21:56:14 +09:00
LICENSES rename crate to scoped-error and relicense to Apache-2.0 with LLVM exception 2026年05月20日 22:04:44 +09:00
src context: implement anyhow style Context trait 2026年06月23日 21:56:14 +09:00
tests rename .error_report() to .report() 2026年05月21日 18:56:04 +09:00
.gitignore feat: initial version 2026年05月15日 21:55:34 +09:00
Cargo.lock crate: bump version to 0.1.5 2026年06月23日 21:59:07 +09:00
Cargo.toml crate: bump version to 0.1.5 2026年06月23日 21:59:07 +09:00
README.md update README.md and crate description 2026年05月22日 22:39:18 +09:00
REUSE.toml rename crate to scoped-error and relicense to Apache-2.0 with LLVM exception 2026年05月20日 22:04:44 +09:00

scoped-error

Structured error handling with semantic context trees.

This library provides scoped_error::Error, a context-aware error type for idiomatic error handling with virtual backtraces - semantic breadcrumbs attached exactly where they matter.

Philosophy

Explicit context over automatic backtraces. Instead of capturing 50 frames of stack on every error, scoped_error lets you attach meaningful context at semantic boundaries. The result is information-dense, user-facing error reports without runtime overhead.

Quick Start

usestd::str::FromStr;usescoped_error::{Error,expect_error};struct Config;implFromStrforConfig{type Err =Error;fn from_str(s: &str)-> Result<Self,Self::Err>{todo!()}}fn read_config()-> Result<String,Error>{expect_error("reading file",||{lettext=std::fs::read_to_string("/etc/app.conf")?;Ok(text)})}fn parse_config(text: &str)-> Result<Config,Error>{expect_error("parsing TOML",||{returnOk(text.parse::<Config>()?);})}fn load_config()-> Result<Config,Error>{expect_error("loading configuration",||{lettext=read_config()?;letcfg=parse_config(&text)?;Ok(cfg)})}fn main()-> Result<(),Error>{let_config=load_config()?;Ok(())}

Output:

Error: loading configuration, at src/main.rs:27:20
|-- reading file, at src/main.rs:15:12
`-- No such file or directory (os error 2)

Multiple Concurrent Failures

Unlike most error libraries, scoped_error natively handles parallel operations with Many:

usescoped_error::Many;letresults=vec![task_a(),task_b(),task_c()];letvalues=Many::from_results("batch operation failed",results)?;

Output:

Error: batch operation failed, at src/main.rs:10:5 (3 errors)
|-- task A failed, at src/worker.rs:8:9
| `-- connection timeout
|-- task B failed, at src/worker.rs:12:9
| `-- invalid response
`-- task C failed, at src/worker.rs:16:9
 `-- parse error

Why scoped_error?

See https://kanru.info/scoped-error/

License

Apache-2.0 WITH LLVM-exception