bevy/crates/bevy_ecs/src
Alice Cecile 7a748e6f0a Make system param validation rely on the unified ECS error handling via the GLOBAL_ERROR_HANDLER (#18454)
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).

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.

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 🥲

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.

`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-25 22:59:01 +01:00
..
entity Replace VisitEntities with MapEntities (#18432) 2025-03-24 00:09:29 +01:00
error Make system param validation rely on the unified ECS error handling via the GLOBAL_ERROR_HANDLER (#18454) 2025-03-25 22:59:01 +01:00
event bevy_reflect: Add clone registrations project-wide (#18307) 2025-03-17 18:32:35 +00:00
identifier bevy_reflect: Add clone registrations project-wide (#18307) 2025-03-17 18:32:35 +00:00
observer Make system param validation rely on the unified ECS error handling via the GLOBAL_ERROR_HANDLER (#18454) 2025-03-25 22:59:01 +01:00
query implement get_many_unique (#18315) 2025-03-16 21:12:26 +00:00
reflect Replace VisitEntities with MapEntities (#18432) 2025-03-24 00:09:29 +01:00
relationship Replace VisitEntities with MapEntities (#18432) 2025-03-24 00:09:29 +01:00
schedule Make system param validation rely on the unified ECS error handling via the GLOBAL_ERROR_HANDLER (#18454) 2025-03-25 22:59:01 +01:00
storage Queued component registration (#18173) 2025-03-10 21:46:27 +00:00
system Make system param validation rely on the unified ECS error handling via the GLOBAL_ERROR_HANDLER (#18454) 2025-03-25 22:59:01 +01:00
world Support skipping Relationship on_replace hooks (#18378) 2025-03-18 01:24:07 +00:00
archetype.rs Fix clippy::let_and_return in bevy_ecs (#18481) 2025-03-24 00:09:30 +01:00
batching.rs Fix *most* clippy lints (#15906) 2024-10-14 20:52:35 +00:00
bundle.rs Fix clippy::let_and_return in bevy_ecs (#18481) 2025-03-24 00:09:30 +01:00
change_detection.rs bevy_reflect: Add clone registrations project-wide (#18307) 2025-03-17 18:32:35 +00:00
component.rs Replace VisitEntities with MapEntities (#18432) 2025-03-24 00:09:29 +01:00
entity_disabling.rs bevy_reflect: Add clone registrations project-wide (#18307) 2025-03-17 18:32:35 +00:00
hierarchy.rs Regression fix: Reintroduce sorting/reordering methods on Children (#18476) 2025-03-24 00:14:22 +01:00
intern.rs Move hashbrown and foldhash out of bevy_utils (#17460) 2025-01-23 16:46:08 +00:00
label.rs do_not_recommend interned Labels (#17950) 2025-02-25 23:46:21 +00:00
lib.rs Make system param validation rely on the unified ECS error handling via the GLOBAL_ERROR_HANDLER (#18454) 2025-03-25 22:59:01 +01:00
name.rs bevy_reflect: Add clone registrations project-wide (#18307) 2025-03-17 18:32:35 +00:00
removal_detection.rs bevy_reflect: Add clone registrations project-wide (#18307) 2025-03-17 18:32:35 +00:00
resource.rs Move Resource trait to its own file (#17469) 2025-01-21 19:47:08 +00:00
spawn.rs Implement SpawnableList for Vec<Bundle> (#18259) 2025-03-11 20:32:37 +00:00
traversal.rs Relationships (non-fragmenting, one-to-many) (#17398) 2025-01-18 22:20:30 +00:00