Macro cosmwasm_std::ensure_eq
source · macro_rules! ensure_eq {
($a:expr, $b:expr, $e:expr) => { ... };
}Expand description
Quick check for a guard. Like assert_eq!, but rather than panic,
it returns the third argument x wrapped in Err(x).
use cosmwasm_std::ensure_eq;
ensure_eq!(info.sender, cfg.admin, ContractError::Unauthorized {});
// is the same as
if info.sender != cfg.admin {
return Err(ContractError::Unauthorized {});
}