diff --git a/crates/bevy_ecs/src/schedule/executor/multi_threaded.rs b/crates/bevy_ecs/src/schedule/executor/multi_threaded.rs index 2d687ed510833..213e438ddb476 100644 --- a/crates/bevy_ecs/src/schedule/executor/multi_threaded.rs +++ b/crates/bevy_ecs/src/schedule/executor/multi_threaded.rs @@ -605,11 +605,17 @@ impl ExecutorState { // access the world data used by the system. // - `update_archetype_component_access` has been called. unsafe { - // TODO: implement an error-handling API instead of suppressing a possible failure. - let _ = __rust_begin_short_backtrace::run_unsafe( + // TODO: implement an error-handling API instead of panicking. + if let Err(err) = __rust_begin_short_backtrace::run_unsafe( system, context.environment.world_cell, - ); + ) { + panic!( + "Encountered an error in system `{}`: {:?}", + &*system.name(), + err + ); + }; }; })); context.system_completed(system_index, res, system); @@ -653,8 +659,14 @@ impl ExecutorState { // that no other systems currently have access to the world. let world = unsafe { context.environment.world_cell.world_mut() }; let res = std::panic::catch_unwind(AssertUnwindSafe(|| { - // TODO: implement an error-handling API instead of suppressing a possible failure. - let _ = __rust_begin_short_backtrace::run(system, world); + // TODO: implement an error-handling API instead of panicking. + if let Err(err) = __rust_begin_short_backtrace::run(system, world) { + panic!( + "Encountered an error in system `{}`: {:?}", + &*system.name(), + err + ); + }; })); context.system_completed(system_index, res, system); }; diff --git a/crates/bevy_ecs/src/schedule/executor/simple.rs b/crates/bevy_ecs/src/schedule/executor/simple.rs index 5cf03e2088276..e21530736eab0 100644 --- a/crates/bevy_ecs/src/schedule/executor/simple.rs +++ b/crates/bevy_ecs/src/schedule/executor/simple.rs @@ -101,8 +101,14 @@ impl SystemExecutor for SimpleExecutor { } let f = AssertUnwindSafe(|| { - // TODO: implement an error-handling API instead of suppressing a possible failure. - let _ = __rust_begin_short_backtrace::run(system, world); + // TODO: implement an error-handling API instead of panicking. + if let Err(err) = __rust_begin_short_backtrace::run(system, world) { + panic!( + "Encountered an error in system `{}`: {:?}", + &*system.name(), + err + ); + } }); #[cfg(feature = "std")] diff --git a/crates/bevy_ecs/src/schedule/executor/single_threaded.rs b/crates/bevy_ecs/src/schedule/executor/single_threaded.rs index d19a222d3011b..d329d0e09c196 100644 --- a/crates/bevy_ecs/src/schedule/executor/single_threaded.rs +++ b/crates/bevy_ecs/src/schedule/executor/single_threaded.rs @@ -109,8 +109,14 @@ impl SystemExecutor for SingleThreadedExecutor { let f = AssertUnwindSafe(|| { if system.is_exclusive() { - // TODO: implement an error-handling API instead of suppressing a possible failure. - let _ = __rust_begin_short_backtrace::run(system, world); + // TODO: implement an error-handling API instead of panicking. + if let Err(err) = __rust_begin_short_backtrace::run(system, world) { + panic!( + "Encountered an error in system `{}`: {:?}", + &*system.name(), + err + ); + } } else { // Use run_unsafe to avoid immediately applying deferred buffers let world = world.as_unsafe_world_cell(); @@ -118,8 +124,14 @@ impl SystemExecutor for SingleThreadedExecutor { // SAFETY: We have exclusive, single-threaded access to the world and // update_archetype_component_access is being called immediately before this. unsafe { - // TODO: implement an error-handling API instead of suppressing a possible failure. - let _ = __rust_begin_short_backtrace::run_unsafe(system, world); + // TODO: implement an error-handling API instead of panicking. + if let Err(err) = __rust_begin_short_backtrace::run_unsafe(system, world) { + panic!( + "Encountered an error in system `{}`: {:?}", + &*system.name(), + err + ); + } }; } }); diff --git a/crates/bevy_ecs/src/system/mod.rs b/crates/bevy_ecs/src/system/mod.rs index 4a4c9e48af230..ca6e83fada9d5 100644 --- a/crates/bevy_ecs/src/system/mod.rs +++ b/crates/bevy_ecs/src/system/mod.rs @@ -1766,6 +1766,7 @@ mod tests { } #[test] + #[should_panic] fn simple_fallible_system() { fn sys() -> Result { Err("error")?;