Go to file
Michael Pfaff 71385c9e19
Support nested details, add with_backtrace method to IntoContext, impl IntoContext for Detail
2023-07-02 12:07:00 -04:00
examples Support nested details, add with_backtrace method to IntoContext, impl IntoContext for Detail 2023-07-02 12:07:00 -04:00
src Support nested details, add with_backtrace method to IntoContext, impl IntoContext for Detail 2023-07-02 12:07:00 -04:00
.gitignore Where was I? 2022-07-21 20:39:47 -04:00
Cargo.toml Optional feature to wrap backtrace in an Arc to enable a full Clone impl 2023-07-01 12:58:07 -04:00
README.md Refactoring, update docs, API adjustments 2023-06-29 01:51:08 -04:00

README.md

How

A seriously contextual error library that focuses on how you got there. Designed to make debugging easier, how enables you to concisely capture any and all context that could possibly have contributed to an error.

Getting started

A basic example takes just 2 imports:

use how::{How, Result};

fn main() -> Result<()> {
	Err(How::new("TODO: implement amazing new program"))
}

But usually you'll want to attach some information too:

use how::{How, Explain, Result};

fn main() -> Result<()> {
	Err(How::new("TODO: implement amazing new program")
        .context("I plan to do it eventually™"))
}

And you'll probably want to get nicer output when you return an error from main (this one requires feature = "termination"):

use how::{How, Explain, Result, TerminationResult};

fn main() -> TerminationResult<()> {
	Err(How::new("TODO: implement amazing new program")
        .context("I plan to do it eventually™"))
        .into()
}

[How] intentionally omits a [From] implementation for Error to discourage the creation of [How]s with no caller context. Instead, the [Explain] trait is implemented for all [Result]1 and [Option] and provides a convenient context function.


  1. Where E is either [How] or implements Error + 'static. ↩︎