pub fn as_model_error<E>(
error_type: ModelErrorType,
message: impl Into<String>,
) -> impl FnOnce(E) -> ModelErrorExpand description
Helper function for .map_err() chains to wrap any error as ModelError.
This function creates a closure that converts any error into a ModelError
with the specified error type and message, including the original error as the source.
§Examples
ⓘ
// Instead of:
.map_err(|e| ModelError::new(ModelErrorType::Generic, e.to_string(), Some(e.into())))?
// You can write:
.map_err(as_model_error(ModelErrorType::Generic, "Failed to process".to_string()))?