Crates.io | eliza_error |
lib.rs | eliza_error |
version | 0.99.1 |
source | src |
created_at | 2019-10-16 00:19:19.945357 |
updated_at | 2019-10-16 00:28:04.325696 |
description | “Times are bad. Children no longer obey their parents, and everyone is writing an error handling library.” — Cicero |
homepage | https://github.com/hawkw/eliza_error |
repository | https://github.com/hawkw/eliza_error |
max_upload_size | |
id | 172839 |
size | 6,744 |
“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.
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(())
}
eliza_error
has no dependencies!eliza_error
can throw exceptions!eliza_error
will support backtraces soon!