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.
```rust use uerr::UserError;
fn sampleerror() { UserError::from("could not open file") .andreason("The system cannot find the file specified.") .andhelp("Does this file exist?") .printall("uerr/error: "); } ```
text
uerr/error: could not open file
- caused by: The system cannot find the file specified.
+ help: Does this file exist?
text
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.
```rust
fn sampleerror() { UserError::from("could not open file") .andreason("The system cannot find the file specified.") .andreason("Filler reason.") .andhelp("Does this file exist?") .andhelp("Filler help.") .printall("program.exe: "); } ```
The UserError
struct also supports inline exiting.
```rust
fn sampleerror() { UserError::from("Sample Error") .printall("my program: ") .exit(-1); } ```