try_or_err

Macro try_or_err 

Source
macro_rules! try_or_err {
    ($result:expr, $error:expr $(,)?) => { ... };
}
Expand description

Tries to unwrap the Result, otherwise returns the error

§Example

fn function_returning_result() -> Result<u64> {
    err!(ErrorCode::MyError)
}

let my_value = try_or_err!(function_returning_result(), ErrorCode::MyError);