eyre

Macro eyre

Source
macro_rules! eyre {
    ($msg:literal $(,)?) => { ... };
    ($err:expr $(,)?) => { ... };
    ($fmt:expr, $($arg:tt)*) => { ... };
}
Expand description

Construct an ad-hoc error from a string.

This evaluates to a Report. It can take either just a string, or a format string with arguments. It also can take any custom type which implements Debug and Display.

ยงExample

use eyre::{eyre, Result};

fn lookup(key: &str) -> Result<V> {
    if key.len() != 16 {
        return Err(eyre!("key length must be 16 characters, got {:?}", key));
    }

    // ...
}