No description
This repository has been archived on 2025-10-15. You can view files and clone it, but you cannot make any changes to its state, such as pushing and creating new issues, pull requests or comments.
Find a file
2023-06-29 01:54:04 -04:00
examples Improved output and API 2023-06-29 00:00:42 -04:00
src Forgot to remove these features 2023-06-29 01:54:04 -04:00
.gitignore Where was I? 2022-07-21 20:39:47 -04:00
Cargo.toml Bump version 2023-06-29 01:51:56 -04:00
README.md Refactoring, update docs, API adjustments 2023-06-29 01:51:08 -04:00

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. ↩︎