bevy/crates/bevy_internal
François 258f495352 log spans on panic when trace is enabled (#3848)
# Objective

- Help debug panics

## Solution

- Insert a custom panic hook when trace is enabled that will log spans

example when running a command on a despawned entity

before:
```
thread 'main' panicked at 'Could not add a component (of type `panic::Marker`) to entity 1v0 because it doesn't exist in this World.
If this command was added to a newly spawned entity, ensure that you have not despawned that entity within the same stage.
This may have occurred due to system order ambiguity, or if the spawning system has multiple command buffers', /bevy/crates/bevy_ecs/src/system/commands/mod.rs:664:13
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
```


after:
```
   0: bevy_ecs::schedule::stage::system_commands
           with name="panic::my_bad_system"
             at crates/bevy_ecs/src/schedule/stage.rs:871
   1: bevy_ecs::schedule::stage
           with name=Update
             at crates/bevy_ecs/src/schedule/mod.rs:340
   2: bevy_app::app::frame
             at crates/bevy_app/src/app.rs:111
   3: bevy_app::app::bevy_app
             at crates/bevy_app/src/app.rs:126
thread 'main' panicked at 'Could not add a component (of type `panic::Marker`) to entity 1v0 because it doesn't exist in this World.
If this command was added to a newly spawned entity, ensure that you have not despawned that entity within the same stage.
This may have occurred due to system order ambiguity, or if the spawning system has multiple command buffers', /bevy/crates/bevy_ecs/src/system/commands/mod.rs:664:13
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
```
2022-02-28 22:27:20 +00:00
..
src Internal Asset Hot Reloading (#3966) 2022-02-18 22:56:57 +00:00
Cargo.toml log spans on panic when trace is enabled (#3848) 2022-02-28 22:27:20 +00:00