Skip to main content

chatbot_err

Macro chatbot_err 

Source
macro_rules! chatbot_err {
    (ChatbotErrorType :: $variant:ident, $msg:expr) => { ... };
    (ChatbotErrorType :: $variant:ident, $msg:expr, $src:expr) => { ... };
    (ChatbotErrorType :: $variant:ident $payload:tt, $msg:expr) => { ... };
    (ChatbotErrorType :: $variant:ident $payload:tt, $msg:expr, $src:expr) => { ... };
    ($variant:ident $payload:tt, $msg:expr) => { ... };
    ($variant:ident $payload:tt, $msg:expr, $src:expr) => { ... };
    ($variant:ident, $msg:expr) => { ... };
    ($variant:ident, $msg:expr, $src:expr) => { ... };
}
Expand description

Create a ChatbotError with less boilerplate.

§Examples

// Without source
let err = chatbot_err!(Generic, "message".to_string());

// With source
let err = chatbot_err!(Generic, "message".to_string(), source_err);

// With format!
let err = chatbot_err!(Generic, format!("Failed: {}", detail));

// With tuple variant payload
let err = chatbot_err!(UnauthorizedWithReason(reason), "message".to_string());

// With struct variant payload
let err = chatbot_err!(BadRequestWithData { code: "x" }, "message".to_string());