macro_rules! map_to_error {
    ($error:ident :: $error_reason:ident) => { ... };
}
Expand description

Helper for mapping errors from one to another

Usage

Error Mapping

The explicit way

let asset = fs::read_to_string(path).map_err(|error| {
SchemaError::IoError(format!("SchemaError::IoError cased by {error}"))
})?;

The above code can be simplified using map_to_error! macro

let result: Result<(), Error> = Err(Error("Test".to_string()));
let mapped_result = result.map_err(map_to_error!(InputError::IllegalArgument));