#error #exception #failure

eliza_error

“Times are bad. Children no longer obey their parents, and everyone is writing an error handling library.” — Cicero

2 releases

0.99.1 Oct 16, 2019
0.99.0 Oct 16, 2019

#727 in Rust patterns

Download history 59/week @ 2021-01-16 97/week @ 2021-01-23 31/week @ 2021-01-30 53/week @ 2021-02-06 72/week @ 2021-02-13 43/week @ 2021-02-20 46/week @ 2021-02-27 19/week @ 2021-03-06 20/week @ 2021-03-13 13/week @ 2021-03-20 11/week @ 2021-03-27 3/week @ 2021-04-03 16/week @ 2021-04-10 11/week @ 2021-04-17 2/week @ 2021-04-24 12/week @ 2021-05-01

177 downloads per month

WTFPL license

5KB

“Times are bad. Children no longer obey their parents, and everyone is writing an error handling library.” — Cicero

fast, cheap, and out of control exceptions for rust.

Usage

First, add this to your Cargo.toml:

[dependencies]
eliza_error = "0.99.0";

You can now throw exceptions!

use eliza_error::{Error, throw};

fn my_great_function() -> Result<(), Error> {
    if is_everything_terrible() {
        throw!("everything is terrible!");
    }
    Ok(())
}

Eliza errors also work fine with errors from the standard library.

use eliza_error::{Error, throw};
use std::fs::File;
use std::io::prelude::*;

fn look_at_file() -> Result<(), Error> {
    let mut file = File::open("this_file_doesnt_exist.txt")?;
    let mut contents = String::new();
    file.read_to_string(&mut contents)?;
    if contents == "everything is terrible!!!" {
        throw!("wow, everything is still terrible!!!");
    }
    Ok(())
}

Why should I use this?

No runtime deps