Skip to content

Commit a59d012

Browse files
Clean up unified error handling migration guides and mention anyhow (#2057)
1 parent 1f7de46 commit a59d012

File tree

4 files changed

+28
-5
lines changed

4 files changed

+28
-5
lines changed

content/learn/migration-guides/0.15-to-0.16.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,8 @@ weight = 11
66
long_title = "Migration Guide: 0.15 to 0.16"
77
+++
88

9+
The most important changes to be aware of this release are:
10+
11+
- Bevy has reworked its error handling to make it easier to handle `Result`s everywhere. As a result, `Query::single` and friends now return results, rather than panicking.
12+
913
{{ migration_guides(version="0.16") }}
Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,8 @@
1-
This change should be pretty much non-breaking, except for users who have implemented their own custom executors. Those users should use `ScheduleSystem` in place of `BoxedSystem<(), ()>` and import the `System` trait where needed. They can choose to do whatever they wish with the result.
1+
Users who have implemented their own custom executor should use `ScheduleSystem` in place of `BoxedSystem<(), ()>` and import the `System` trait where needed.
2+
3+
Custom executors should:
4+
5+
- obey the `SystemParamValidationError` returned by `SystemParam::validate_param`, skipping systems as requested
6+
- use the `default_error_handler` for both validation errors and results returned from systems
7+
8+
See the source code of the first-party Bevy schedule executors for more details.

release-content/0.16/migration-guides/18082_Make_Querysingle_and_friends_return_a_Result.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,15 @@
55
- Use `unwrap()` or `Ok` destructuring inside of tests.
66

77
The old `Query::get_single` (etc) methods which did this have been deprecated.
8+
9+
If you are using `anyhow`, you will experience namespace clashes between Bevy's catch-all `Result` and `anyhow`'s type of the same name.
10+
Within Bevy-specific projects, you should migrate to use the `bevy::ecs::error::Result` due to its better backtraces, and file requests for any missing functionality.
11+
For projects that support both Bevy and non-Bevy users, you should define a feature-gated type alias and avoid glob-importing `bevy::prelude`:
12+
13+
```rust
14+
#[cfg(feature="bevy")]
15+
type Result = bevy::ecs::error::Result;
16+
17+
#[cfg(not(feature="bevy"))]
18+
type Result = anyhow::Result;
19+
```

release-content/0.16/migration-guides/_guides.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,8 @@ areas = ["ECS"]
167167
file_name = "17602_Encapsulate_cfgfeature__track_location_in_a_type.md"
168168

169169
[[guides]]
170-
title = "Fallible systems"
171-
prs = [16589]
170+
title = "Fallible systems and custom schedule executors"
171+
prs = [16589, 18541, 18666]
172172
areas = ["ECS"]
173173
file_name = "16589_Fallible_systems.md"
174174

@@ -221,8 +221,8 @@ areas = ["ECS"]
221221
file_name = "17671_Isolate_component_registration.md"
222222

223223
[[guides]]
224-
title = "Make Query::single (and friends) return a Result"
225-
prs = [18082]
224+
title = "Unified error handling"
225+
prs = [18082, 18144]
226226
areas = ["ECS"]
227227
file_name = "18082_Make_Querysingle_and_friends_return_a_Result.md"
228228

0 commit comments

Comments
 (0)