bevy/crates
Alice Cecile ce7d4e41d6
Make system param validation rely on the unified ECS error handling via the GLOBAL_ERROR_HANDLER (#18454)
# Objective

There are two related problems here:

1. Users should be able to change the fallback behavior of *all*
ECS-based errors in their application by setting the
`GLOBAL_ERROR_HANDLER`. See #18351 for earlier work in this vein.
2. The existing solution (#15500) for customizing this behavior is high
on boilerplate, not global and adds a great deal of complexity.

The consensus is that the default behavior when a parameter fails
validation should be set based on the kind of system parameter in
question: `Single` / `Populated` should silently skip the system, but
`Res` should panic. Setting this behavior at the system level is a
bandaid that makes getting to that ideal behavior more painful, and can
mask real failures (if a resource is missing but you've ignored a system
to make the Single stop panicking you're going to have a bad day).

## Solution

I've removed the existing `ParamWarnPolicy`-based configuration, and
wired up the `GLOBAL_ERROR_HANDLER`/`default_error_handler` to the
various schedule executors to properly plumb through errors .

Additionally, I've done a small cleanup pass on the corresponding
example.

## Testing

I've run the `fallible_params` example, with both the default and a
custom global error handler. The former panics (as expected), and the
latter spams the error console with warnings 🥲

## Questions for reviewers

1. Currently, failed system param validation will result in endless
console spam. Do you want me to implement a solution for warn_once-style
debouncing somehow?
2. Currently, the error reporting for failed system param validation is
very limited: all we get is that a system param failed validation and
the name of the system. Do you want me to implement improved error
reporting by bubbling up errors in this PR?
3. There is broad consensus that the default behavior for failed system
param validation should be set on a per-system param basis. Would you
like me to implement that in this PR?

My gut instinct is that we absolutely want to solve 2 and 3, but it will
be much easier to do that work (and review it) if we split the PRs
apart.

## Migration Guide

`ParamWarnPolicy` and the `WithParamWarnPolicy` have been removed
completely. Failures during system param validation are now handled via
the `GLOBAL_ERROR_HANDLER`: please see the `bevy_ecs::error` module docs
for more information.

---------

Co-authored-by: MiniaczQ <xnetroidpl@gmail.com>
2025-03-24 05:58:05 +00:00
..
bevy_a11y Remove bevy_input_focus from bevy_a11y (#18483) 2025-03-22 12:37:42 +00:00
bevy_animation bevy_reflect: Add clone registrations project-wide (#18307) 2025-03-17 18:32:35 +00:00
bevy_anti_aliasing Ensure dds enables bevy_core_pipeline/dds in bevy_anti_aliasing (#18484) 2025-03-22 12:27:14 +00:00
bevy_app Create new NonSendMarker (#18301) 2025-03-23 21:37:40 +00:00
bevy_asset fix error and lints when building for wasm32 (#18500) 2025-03-23 22:06:28 +00:00
bevy_audio bevy_reflect: Add clone registrations project-wide (#18307) 2025-03-17 18:32:35 +00:00
bevy_color bevy_reflect: Add clone registrations project-wide (#18307) 2025-03-17 18:32:35 +00:00
bevy_core_pipeline Add bevy_anti_aliasing (#18323) 2025-03-19 18:40:32 +00:00
bevy_derive Link iOS example with rustc, and avoid C trampoline (#14780) 2025-03-17 21:14:07 +00:00
bevy_dev_tools Generic system config (#17962) 2025-03-12 00:12:30 +00:00
bevy_diagnostic Add process cpu/memory usage to SystemInformationDiagnosticsPlugin (#18279) 2025-03-16 21:14:46 +00:00
bevy_dylib enable std when building bevy_dylib (#18405) 2025-03-19 00:49:26 +00:00
bevy_ecs Make system param validation rely on the unified ECS error handling via the GLOBAL_ERROR_HANDLER (#18454) 2025-03-24 05:58:05 +00:00
bevy_encase_derive Internalize BevyManifest logic. Switch to RwLock (#18263) 2025-03-12 00:46:01 +00:00
bevy_gilrs Replace some !Send resources with thread_local! (#17730) 2025-03-04 07:48:02 +00:00
bevy_gizmos Extract sprites into a Vec (#17619) 2025-03-18 00:48:33 +00:00
bevy_gltf fix error and lints when building for wasm32 (#18500) 2025-03-23 22:06:28 +00:00
bevy_image Ensure dds enables bevy_core_pipeline/dds in bevy_anti_aliasing (#18484) 2025-03-22 12:27:14 +00:00
bevy_input bevy_reflect: Add clone registrations project-wide (#18307) 2025-03-17 18:32:35 +00:00
bevy_input_focus bevy_reflect: Add clone registrations project-wide (#18307) 2025-03-17 18:32:35 +00:00
bevy_internal enable x11 by default in bevy_winit (#18475) 2025-03-23 23:52:58 +00:00
bevy_log Add print_stdout and print_stderr lints (#17446) (#18233) 2025-03-11 19:35:48 +00:00
bevy_macro_utils Switch to ImDocument in BevyManifest (#18272) 2025-03-12 20:15:39 +00:00
bevy_math bevy_reflect: Add clone registrations project-wide (#18307) 2025-03-17 18:32:35 +00:00
bevy_mesh bevy_reflect: Add clone registrations project-wide (#18307) 2025-03-17 18:32:35 +00:00
bevy_mikktspace Add print_stdout and print_stderr lints (#17446) (#18233) 2025-03-11 19:35:48 +00:00
bevy_pbr Add bevy_anti_aliasing (#18323) 2025-03-19 18:40:32 +00:00
bevy_picking Unify picking backends (#17348) 2025-03-18 19:24:43 +00:00
bevy_platform_support Address lints in bevy_platform_support (#18477) 2025-03-22 11:21:18 +00:00
bevy_ptr moved Debug from derive to impl_ptr in bevy_ptr (#18042) 2025-02-28 02:54:46 +00:00
bevy_reflect Address Lints in bevy_reflect (#18479) 2025-03-23 23:53:31 +00:00
bevy_remote fix error and lints when building for wasm32 (#18500) 2025-03-23 22:06:28 +00:00
bevy_render Make system param validation rely on the unified ECS error handling via the GLOBAL_ERROR_HANDLER (#18454) 2025-03-24 05:58:05 +00:00
bevy_scene Properly gate imports in bevy_scene (#18482) 2025-03-22 12:22:20 +00:00
bevy_sprite Newtype Anchor (#18439) 2025-03-21 22:27:11 +00:00
bevy_state bevy_reflect: Add clone registrations project-wide (#18307) 2025-03-17 18:32:35 +00:00
bevy_tasks Fix clippy warning about unnecessary return in single_threaded_taks_pool.rs (#18472) 2025-03-22 09:03:29 +00:00
bevy_text Newtype Anchor (#18439) 2025-03-21 22:27:11 +00:00
bevy_time Fix clippy::unnecessary-literal-unwrap in bevy_time (#18485) 2025-03-22 13:27:37 +00:00
bevy_transform Revert "Transform Propagation Optimization: Static Subtree Marking (#18094)" (#18363) 2025-03-17 20:01:29 +00:00
bevy_ui register ComputedNodeTarget (#18503) 2025-03-23 23:50:15 +00:00
bevy_utils Address clippy::let_and_return in bevy_utils (#18480) 2025-03-22 11:44:49 +00:00
bevy_window Replace VisitEntities with MapEntities (#18432) 2025-03-21 00:18:10 +00:00
bevy_winit enable x11 by default in bevy_winit (#18475) 2025-03-23 23:52:58 +00:00