Use Display instead of Debug in the default error handler#18629
Merged
alice-i-cecile merged 2 commits intobevyengine:mainfrom Mar 31, 2025
Merged
Use Display instead of Debug in the default error handler#18629alice-i-cecile merged 2 commits intobevyengine:mainfrom
alice-i-cecile merged 2 commits intobevyengine:mainfrom
Conversation
Include backtraces in Display so that they are still rendered.
chescock
commented
Mar 30, 2025
| // If we run the app, we'll see the following output at startup: | ||
| // | ||
| // WARN Encountered an error in system `fallible_systems::failing_system`: "Resource not initialized" | ||
| // WARN Encountered an error in system `fallible_systems::failing_system`: Resource not initialized |
Contributor
Author
There was a problem hiding this comment.
I changed this line of documentation because we'll no longer print the quotes, but the example doesn't actually output this error! The sole use of failing_system is used with pipe to handle the result.
ItsDoot
approved these changes
Mar 30, 2025
JaySpruce
approved these changes
Mar 30, 2025
bushrat011899
approved these changes
Mar 31, 2025
mockersf
pushed a commit
that referenced
this pull request
Mar 31, 2025
# Objective Improve error messages for missing resources. The default error handler currently prints the `Debug` representation of the error type instead of `Display`. Most error types use `#[derive(Debug)]`, resulting in a dump of the structure, but will have a user-friendly message for `Display`. Follow-up to #18593 ## Solution Change the default error handler to use `Display` instead of `Debug`. Change `BevyError` to include the backtrace in the `Display` format in addition to `Debug` so that it is still included. ## Showcase Before: ``` Encountered an error in system `system_name`: SystemParamValidationError { skipped: false, message: "Resource does not exist", param: "bevy_ecs::change_detection::Res<app_name::ResourceType>" } Encountered an error in system `other_system_name`: "String message with\nmultiple lines." ``` After ``` Encountered an error in system `system_name`: Parameter `Res<ResourceType>` failed validation: Resource does not exist Encountered an error in system `other_system_name`: String message with multiple lines. ```
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Objective
Improve error messages for missing resources.
The default error handler currently prints the
Debugrepresentation of the error type instead ofDisplay. Most error types use#[derive(Debug)], resulting in a dump of the structure, but will have a user-friendly message forDisplay.Follow-up to #18593
Solution
Change the default error handler to use
Displayinstead ofDebug.Change
BevyErrorto include the backtrace in theDisplayformat in addition toDebugso that it is still included.Showcase
Before:
After