macro_rules! error {
($code:expr) => { ... };
($code:expr, $msg:literal) => { ... };
($code:expr, $fmt:literal, $($args:expr),+ $(,)?) => { ... };
}Expand description
Creates an Error with the specified ErrorCode and optional formatted
message.
This macro provides a convenient and efficient way to construct Error
instances with compile-time optimizations and meaningful default messages.
§Arguments
$code- AnErrorCodevariant that categorizes the error type$msg- (Optional) A string literal for static messages$fmt- (Optional) A format string literal with{}placeholders$args- (Optional) Arguments corresponding to format placeholders
§See Also
format!- For understanding format string syntaxError::new- The underlying constructor being calledstd::fmt- For advanced formatting options