Skip to main content

missing_chatbot_error

Function missing_chatbot_error 

Source
pub fn missing_chatbot_error(
    error_type: ChatbotErrorType,
    message: impl Into<String>,
) -> impl FnOnce() -> ChatbotError
Expand description

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

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

§Examples

// Instead of:
.ok_or_else(|| ChatbotError::new(ChatbotErrorType::Other, "Item not found".to_string(), None))

// You can write:
.ok_or_else(missing_chatbot_error(ChatbotErrorType::Other, "Item not found".to_string()))