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