macro_rules! fail {
($err:expr $(,)?) => { ... };
}Expand description
Abort the enclosing function with the provided error.
This macro is a typed alternative to anyhow::bail!, delegating the
decision of how to construct the error to the caller. It never performs
formatting or allocations on the success path.
ยงExamples
use masterror::{AppError, AppErrorKind, AppResult};
fn reject() -> AppResult<()> {
masterror::fail!(AppError::unauthorized("token expired"));
}
let err = reject().unwrap_err();
assert!(matches!(err.kind, AppErrorKind::Unauthorized));