Skip to main content

bevy_error

Macro bevy_error 

Source
macro_rules! bevy_error {
    ($fmt:literal) => { ... };
    ($fmt:literal, $($arg:tt)*) => { ... };
    ($severity:expr, $fmt:literal) => { ... };
    ($severity:expr, $fmt:literal, $($arg:tt)*) => { ... };
    ($severity:expr) => { ... };
}
Expand description

Creates a new BevyError from a string.

Strings can be formatted like the format! macro. Severity can optionally be provided to change it from the default Severity::Panic. This can be done by adding the severity as the fist argument.

ยงExample

use bevy_ecs::{bevy_error, error::{BevyError, Severity}};

fn this_will_fail(value: u32) -> Result<(), BevyError> {
    if value == 0 {
        return Err(bevy_error!(Severity::Debug, "A debug message"));
    } else {
        return Err(bevy_error!("We can even do formatting {value}, {}", "hello"));
    }
}