Add `bevy_error!` and `bail!` macros to `BevyError` (#23720)
# Objective
These macros were originally part of #23684 but were removed to help the
pr cross the finish line.
## Solution
Reintroduce and discuss them here.
## Testing
2 testcases to prove the expanded code compiles.
---
`bevy_ecs` has been expanded with 2 macros to simplify creation of
`BevyError`s.
```rust
// Now instead of this.
let error = BevyError::new(Severity::Panic, "hello error");
// You can do this. It even support `format!` syntax
let error = bevy_error!("{} bottles of beer on the wall.", 99);
// Quickly return from a fallible system using bail.
bail!("{} bottles of beer.", 99);
// Expands to something like this
return Err(BevyError::panic("Take on down, pass it around,");
// You can even specify the severity by passing it in as the first argument
bevy_error!(Severity::Debug, "{} bottles of beer on the wall.", 98);
``` L
loreball committed
19dd0c02d78544fed37b8dd7da73bf922d106810
Parent: afd576f
Committed by GitHub <noreply@github.com>
on 5/21/2026, 8:57:22 AM