macro_rules! msg_error_anyhow {
($msg:expr) => { ... };
}Expand description
Builds an anyhow::Error from the message.
Unmarked: the mark belongs to where the error is printed, which knows
whether it is ❌ for a person or error: for --plain
(crate::libs::output::report_error).
use anyhow::Result;
use kasl::{msg_error_anyhow, libs::messages::Message};
fn validate_config() -> Result<()> {
if config_is_invalid() {
return Err(msg_error_anyhow!(Message::ConfigParseError));
}
Ok(())
}use anyhow::{Result, Context};
use kasl::{msg_error_anyhow, libs::messages::Message};
fn complex_operation() -> Result<()> {
some_operation()
.context(msg_error_anyhow!(Message::TaskUpdateFailed))
}