Rust Anyhow
anyhow
is a rust library to type erase different error types. This simplifies error propagation in user code.
Context
We can wrap an anyhow::Result
with additional context information with .context()
:
result.context("additional info")
There is also a lazy version .with_context()
:
result.with_context(|| format!("Failed to read instrs from {}", path.display()))
See Also
- std::error_code - C++ facility to type erase error code enums