Crates.io | uerr |
lib.rs | uerr |
version | 0.1.0 |
source | src |
created_at | 2022-07-15 05:02:39.50129 |
updated_at | 2022-07-15 05:02:39.50129 |
description | A crate which provides stunning visual error handling. |
homepage | |
repository | |
max_upload_size | |
id | 626022 |
size | 8,085 |
uerr
is a crate which provides stunning visual error handling.
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: ");
}
uerr/error: could not open file
- caused by: The system cannot find the file specified.
+ help: Does this file exist?
program.exe: could not open file
- caused by: The system cannot find the file specified.
| Filler reason.
+ help: Does this file exist?
| Filler help.
#[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: ");
}
The UserError
struct also supports inline exiting.
#[test]
fn sample_error() {
UserError::from("Sample Error")
.print_all("my program: ")
.exit(-1);
}