bevy/crates/bevy_ecs/src/error
Chris Russell b4614dadcd
Use Display instead of Debug in the default error handler (#18629)
# 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.
```
2025-03-31 18:28:19 +00:00
..
bevy_error.rs Use Display instead of Debug in the default error handler (#18629) 2025-03-31 18:28:19 +00:00
command_handling.rs Unify and simplify command and system error handling (#18351) 2025-03-18 19:27:50 +00:00
handler.rs Use Display instead of Debug in the default error handler (#18629) 2025-03-31 18:28:19 +00:00
mod.rs Unify and simplify command and system error handling (#18351) 2025-03-18 19:27:50 +00:00