bevy/examples/ecs
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
..
change_detection.rs
component_hooks.rs
custom_query_param.rs
custom_schedule.rs
dynamic.rs
ecs_guide.rs
entity_disabling.rs
error_handling.rs Use Display instead of Debug in the default error handler (#18629) 2025-03-31 18:28:19 +00:00
event.rs
fallible_params.rs
fixed_timestep.rs
generic_system.rs
hierarchy.rs
immutable_components.rs
iter_combinations.rs
nondeterministic_system_order.rs
observer_propagation.rs
observers.rs
one_shot_systems.rs
parallel_query.rs
relationships.rs
removal_detection.rs
run_conditions.rs
send_and_receive_events.rs
startup_system.rs
system_closure.rs
system_param.rs
system_piping.rs
system_stepping.rs