Skip to content

Mention Option and When in the error message for a failing system parameter#19490

Merged
alice-i-cecile merged 1 commit intobevyengine:mainfrom
chescock:mention-when-in-parameter-failure-error-message
Jun 4, 2025
Merged

Mention Option and When in the error message for a failing system parameter#19490
alice-i-cecile merged 1 commit intobevyengine:mainfrom
chescock:mention-when-in-parameter-failure-error-message

Conversation

@chescock
Copy link
Contributor

@chescock chescock commented Jun 4, 2025

Objective

Help users discover how to use Option<T> and When<T> to handle failing parameters.

Solution

Have the error message for a failed parameter mention that Option<T> and When<T> can be used to handle the failure.

Showcase

Encountered an error in system `system_name`: Parameter `Res<ResourceType>` failed validation: Resource does not exist
If this is an expected state, wrap the parameter in `Option<T>` and handle `None` when it happens, or wrap the parameter in `When<T>` to skip the system when it happens.

@alice-i-cecile alice-i-cecile added A-ECS Entities, components, systems, and events C-Usability A targeted quality-of-life change that makes Bevy easier to use X-Uncontroversial This work is generally agreed upon S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Jun 4, 2025
@alice-i-cecile alice-i-cecile added D-Trivial Nice and easy! A great choice to get started with Bevy S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it and removed S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Jun 4, 2025
@alice-i-cecile alice-i-cecile enabled auto-merge June 4, 2025 16:24
@alice-i-cecile
Copy link
Member

Lovely; that's exactly the sort of polish that goes a long way.

@alice-i-cecile alice-i-cecile added this pull request to the merge queue Jun 4, 2025
Merged via the queue into bevyengine:main with commit bd4c960 Jun 4, 2025
45 checks passed
VitalyAnkh pushed a commit to VitalyAnkh/bevy that referenced this pull request Jun 8, 2025
… parameter (bevyengine#19490)

# Objective

Help users discover how to use `Option<T>` and `When<T>` to handle
failing parameters.

## Solution

Have the error message for a failed parameter mention that `Option<T>`
and `When<T>` can be used to handle the failure.

## Showcase

```
Encountered an error in system `system_name`: Parameter `Res<ResourceType>` failed validation: Resource does not exist
If this is an expected state, wrap the parameter in `Option<T>` and handle `None` when it happens, or wrap the parameter in `When<T>` to skip the system when it happens.
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-ECS Entities, components, systems, and events C-Usability A targeted quality-of-life change that makes Bevy easier to use D-Trivial Nice and easy! A great choice to get started with Bevy S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it X-Uncontroversial This work is generally agreed upon

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants