macro_rules! bail {
($($args:tt)+) => { ... };
}Expand description
Returns early with an error.
Equivalent to return Err(bevy_error!(...))
As a result the returned error defaults to Severity::Panic. As with
bevy_error! the severity can be changed by providing a severity as the
first argument. To return early only when a condition is false, use
ensure!.
ยงExample
use bevy_ecs::{bail, error::{BevyError, Severity}};
fn do_some_stuff(val: i32) -> Result<(), BevyError> {
if val < 0 {
bail!(Severity::Warning, "Something is broken: {}", val);
} else if val == 0 {
bail!("Value really can't be zero");
}
// ...
Ok(())
}