handle

Macro handle 

Source
macro_rules! handle {
    ($result:expr, $variant:ident$(,)? $($arg:ident$(: $value:expr)?),*) => { ... };
}
Expand description

handle! is a better alternative to map_err because it doesn’t capture any variables from the environment if the result is Ok, only when the result is Err. By contrast, a closure passed to map_err always captures the variables from environment, regardless of whether the result is Ok or Err Use handle! if you need to pass owned variables to an error variant (which is returned only in case when result is Err) In addition, this macro captures the original error in the source variable, and sets it as the source key of the error variant

Note: handle! assumes that your error variant is a struct variant