missing_model_error

Function missing_model_error 

Source
pub fn missing_model_error(
    error_type: ModelErrorType,
    message: impl Into<String>,
) -> impl FnOnce() -> ModelError
Expand description

Helper function for .ok_or_else() to create ModelError on None.

This function creates a closure that generates a ModelError with the specified error type and message when called.

§Examples

// Instead of:
.ok_or_else(|| ModelError::new(ModelErrorType::NotFound, "Item not found".to_string(), None))

// You can write:
.ok_or_else(missing_model_error(ModelErrorType::NotFound, "Item not found".to_string()))