handle-error

An error handling / bubbling macro to reduce rust error handling boilerplate.

GitHub tag Travis Build Status Crates.io Docs.rs

For a given fallible expression (expression returning a result), such as:

rust fn do_something() -> Result<(), E> { // .... }

This can be used as follows:

```rust

[macro_use]

extern crate log;

[macro_use]

extern crate handle_error;

fn main() -> Result<(), E> { let v = handleerror!(dosomething(), "Failed to do something"); Ok(()) } ```

Replacing the common patterns:

```rust

[macro_use]

extern crate log;

// Match case where we care about the ok value fn exampleone() -> Result<(), E> { let v = match dosomething() { Ok(v) => v, Err(e) => { error!("Failed to do something"); return Err(e); } };

Ok(()) }

// If let where we do not care about the ok value fn exampletwo() -> Result<(), E> { if let Err(e) = dosomething() { error!("Failed to do something"); return Err(e); }

Ok(()) } ```