Macro cosmwasm_std::ensure
source ยท macro_rules! ensure { ($cond:expr, $e:expr) => { ... }; }
Expand description
Quick check for a guard. If the condition (first argument) is false,
then return the second argument x
wrapped in Err(x)
.
use cosmwasm_std::ensure;
ensure!(permissions.delegate, ContractError::DelegatePerm {});
// is the same as
if !permissions.delegate {
return Err(ContractError::DelegatePerm {});
}