macro_rules! bail {
($msg:literal $(,)?) => { ... };
($err:expr $(,)?) => { ... };
($fmt:expr, $($arg:tt)*) => { ... };
}
Expand description
Return early with an error.
This macro is equivalent to return Err(
error_from!($args...)
)
.
The surrounding function’s or closure’s return value is required to be
Result<_,
narrate::Error
>
.
Example
if !has_permission(user, resource) {
bail!("permission denied for accessing {}", resource);
}