as_util_error

Function as_util_error 

Source
pub fn as_util_error<E>(
    error_type: UtilErrorType,
    message: impl Into<String>,
) -> impl FnOnce(E) -> UtilError
where E: Into<Error>,
Expand description

Helper function for .map_err() chains to wrap any error as UtilError.

This function creates a closure that converts any error into a UtilError with the specified error type and message, including the original error as the source.

§Examples

// Instead of:
.map_err(|e| UtilError::new(UtilErrorType::Other, e.to_string(), Some(e.into())))?

// You can write:
.map_err(as_util_error(UtilErrorType::Other, "Failed to process".to_string()))?