Macro rubbl_core::ctry[][src]

macro_rules! ctry {
    ($op : expr ; $($chain_fmt_args : expr), *) => { ... };
}
Expand description

A “contextualized try” macro.

Attempts an operation that returns a Result and returns its Ok value if the operation is successful. If not, it returns an Err value of type failure::Context that includes explanatory text formatted using the format! macro and chains to the causative error. Example:

ctry!(write!(myfile, "hello"); "couldn\'t write to {}", myfile_path);

Note that the operation to be attempted and the arguments to format! are separated by a semicolon within the ctry!() parentheses.