Macro anyhow::bail [−][src]
Return early with an error.
This macro is equivalent to return Err(From::from($err))
.
Example
if !has_permission(user, resource) { bail!("permission denied for accessing {}", resource); }
#[derive(Error, Debug)] enum ScienceError { #[error("recursion limit exceeded")] RecursionLimitExceeded, ... } if depth > MAX_DEPTH { bail!(ScienceError::RecursionLimitExceeded); }