The aim of this library is to support writing command line programs in Rust by simplifying error handling in program code.

It introduces Problem type which can be used on high level APIs for which error handling boils down to: * reporting error message (e.g. log with error! macro), * aborting program on error other than a bug (e.g. using panic! macro), * ignoring error.

Goals

Non Goals

Example

Implicit conversion to Problem type and context message. ```rust,skt-problem use problem::prelude::*;

fn foo() -> Result { let str = String::from_utf8(vec![0, 123, 255])?; Ok(str) }

let result = foo().problem_while("creating string");

asserteq!(result.unwraperr().to_string(), "while creating string got problem caused by: invalid utf-8 sequence of 1 bytes from index 2"); ```

Handling fatal errors with panic and Problem::or_failed_to. ```rust,shouldpanic,skt-problem use problem::prelude::*; use problem::formatpanictostderr;

formatpanicto_stderr();

fn foo() -> Result { let str = String::from_utf8(vec![0, 123, 255])?; Ok(str) }

let s = foo().orfailed_to("create a string"); // Fatal error: Panicked in src/lib.rs:464:25: Failed to create a string due to: invalid utf-8 sequence of 1 bytes from index 2 ```

For more examples see crate documentation at docs.rs.