uerr

Crates.iouerr
lib.rsuerr
version0.1.0
sourcesrc
created_at2022-07-15 05:02:39.50129
updated_at2022-07-15 05:02:39.50129
descriptionA crate which provides stunning visual error handling.
homepage
repository
max_upload_size
id626022
size8,085
Imajin (ImajinDevon)

documentation

README

uerr

uerr is a crate which provides stunning visual error handling.

Showcase

Using the code below, we can display a simple error and show it to the user.

use uerr::UserError;

#[test]
fn sample_error() {
    UserError::from("could not open file")
        .and_reason("The system cannot find the file specified.")
        .and_help("Does this file exist?")
        .print_all("uerr/error: ");
}

Output

uerr/error: could not open file
 - caused by: The system cannot find the file specified.
 + help: Does this file exist?

With multiple arguments

program.exe: could not open file
 - caused by: The system cannot find the file specified.
     |        Filler reason.
 + help: Does this file exist?
     |   Filler help.
Click to see the code.
#[test]
fn sample_error() {
    UserError::from("could not open file")
        .and_reason("The system cannot find the file specified.")
        .and_reason("Filler reason.")
        .and_help("Does this file exist?")
        .and_help("Filler help.")
        .print_all("program.exe: ");
}

Exiting with errors

The UserError struct also supports inline exiting.

#[test]
fn sample_error() {
    UserError::from("Sample Error")
        .print_all("my program: ")
        .exit(-1);
}
Commit count: 0

cargo fmt