Commit 88035a3
Improve error for when you try running a one-shot system with wrong
# Objective
Improve error message when running a one-shot system with a `SystemId`
of wrong type.
## Solution
Added a resource to keep track of running one-shot systems, and return
`Recursive` error if a system gets run before the end of their previous
invocation. The error for not being able to `take` a `RegisteredSystem`
is now `MaybeWrongType`.
## Testing
Minimal reproduction from #19005
## Showcase
```
// Old
2025-05-01T12:42:54.305283Z WARN bevy_ecs::error::handler: Encountered an error in command `bevy_ecs::system::commands::command::run_system<()>::{{closure}}`: System SystemId(4v1#4294967300) tried to run itself recursively
2025-05-01T12:42:54.305311Z WARN bevy_ecs::error::handler: Encountered an error in command `bevy_ecs::system::commands::command::run_system_with<bevy_ecs::system::input::In<&str>>::{{closure}}`: System SystemId(5v1#4294967301) tried to run itself recursively
// New
2025-05-05T14:21:44.918145Z WARN bevy_ecs::error::handler: Encountered an error in command `bevy_ecs::system::commands::command::run_system<()>::{{closure}}`: Could not get system from `SystemId`, entity was `SystemId<(), Result<(), BevyError>>`
2025-05-05T14:21:44.918177Z WARN bevy_ecs::error::handler: Encountered an error in command `bevy_ecs::system::commands::command::run_system_with<bevy_ecs::system::input::In<&str>>::{{closure}}`: Could not get system from `SystemId<In<&str>>`, entity was `SystemId<In<&str>, Result<(), BevyError>>`
```
## TODO
- [x] Add `TypeId` to `SystemIdMarker`
- [x] Migration guide for new enum variant
---------
Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>SystemId type (#19011)1 parent 44efc81 commit 88035a3
File tree
2 files changed
+94
-16
lines changed- crates/bevy_ecs/src/system
- release-content/migration-guides
2 files changed
+94
-16
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | | - | |
3 | 1 | | |
4 | 2 | | |
5 | 3 | | |
| |||
14 | 12 | | |
15 | 13 | | |
16 | 14 | | |
17 | | - | |
18 | | - | |
19 | | - | |
| 15 | + | |
| 16 | + | |
20 | 17 | | |
21 | 18 | | |
22 | 19 | | |
23 | 20 | | |
24 | | - | |
| 21 | + | |
25 | 22 | | |
26 | 23 | | |
27 | 24 | | |
| |||
36 | 33 | | |
37 | 34 | | |
38 | 35 | | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
39 | 60 | | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
44 | 75 | | |
45 | 76 | | |
46 | 77 | | |
| |||
344 | 375 | | |
345 | 376 | | |
346 | 377 | | |
347 | | - | |
| 378 | + | |
348 | 379 | | |
349 | 380 | | |
350 | | - | |
351 | | - | |
352 | | - | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
353 | 396 | | |
354 | | - | |
| 397 | + | |
355 | 398 | | |
356 | 399 | | |
357 | 400 | | |
| |||
510 | 553 | | |
511 | 554 | | |
512 | 555 | | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
513 | 559 | | |
514 | 560 | | |
515 | 561 | | |
| |||
532 | 578 | | |
533 | 579 | | |
534 | 580 | | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
535 | 586 | | |
536 | 587 | | |
537 | 588 | | |
| |||
542 | 593 | | |
543 | 594 | | |
544 | 595 | | |
545 | | - | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
546 | 600 | | |
547 | 601 | | |
548 | 602 | | |
| |||
986 | 1040 | | |
987 | 1041 | | |
988 | 1042 | | |
| 1043 | + | |
| 1044 | + | |
| 1045 | + | |
| 1046 | + | |
| 1047 | + | |
| 1048 | + | |
| 1049 | + | |
| 1050 | + | |
| 1051 | + | |
| 1052 | + | |
| 1053 | + | |
| 1054 | + | |
| 1055 | + | |
| 1056 | + | |
| 1057 | + | |
| 1058 | + | |
| 1059 | + | |
989 | 1060 | | |
Lines changed: 7 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
0 commit comments