macro_rules! bail {
($err:expr) => { ... };
}Expand description
Early return with an error.
ยงExample
use dbrest::bail;
use dbrest::Error;
fn validate(x: i32) -> Result<(), Error> {
if x < 0 {
bail!(Error::InvalidQueryParam {
param: "x".to_string(),
message: "must be non-negative".to_string(),
});
}
Ok(())
}