Go to file
Michael Pfaff db067003d8
Expose Detail
- Add some accessor methods on `Context`
- Wrap some variants in private structs to prevent people from depending
  on them
- Add some #[inline]
2023-07-01 12:37:14 -04:00
examples Improved output and API 2023-06-29 00:00:42 -04:00
src Expose Detail 2023-07-01 12:37:14 -04:00
.gitignore Where was I? 2022-07-21 20:39:47 -04:00
Cargo.toml Expose Detail 2023-07-01 12:37:14 -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. ↩︎