From 86126003586deeb93b40c3a44f51f2b4f9dfbdad Mon Sep 17 00:00:00 2001 From: Shane Celis Date: Sun, 18 Aug 2024 02:38:09 -0400 Subject: [PATCH 1/4] feature: Send ScriptErrorEvent when load fails. --- crates/bevy_mod_scripting_core/src/hosts.rs | 5 +++++ crates/bevy_mod_scripting_core/src/systems.rs | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/crates/bevy_mod_scripting_core/src/hosts.rs b/crates/bevy_mod_scripting_core/src/hosts.rs index 9e8ff585..43215dd4 100644 --- a/crates/bevy_mod_scripting_core/src/hosts.rs +++ b/crates/bevy_mod_scripting_core/src/hosts.rs @@ -7,6 +7,7 @@ use std::{ }; use crate::{ + ScriptErrorEvent, asset::CodeAsset, docs::DocFragment, error::ScriptError, @@ -358,6 +359,7 @@ impl Script { providers: &mut APIProviders, contexts: &mut ScriptContexts, event_writer: &mut EventWriter, + error_writer: &mut EventWriter, ) { debug!("reloading script {}", script.id); @@ -374,6 +376,7 @@ impl Script { providers, contexts, event_writer, + error_writer, ); } else { // remove old context @@ -392,6 +395,7 @@ impl Script { providers: &mut APIProviders, contexts: &mut ScriptContexts, event_writer: &mut EventWriter, + error_writer: &mut EventWriter, ) { let fd = ScriptData { sid: new_script.id(), @@ -424,6 +428,7 @@ impl Script { // this script will now never execute, unless manually reloaded // but contexts are left in a valid state contexts.insert_context(fd, None); + error_writer.send(ScriptErrorEvent { error: e }); } } } diff --git a/crates/bevy_mod_scripting_core/src/systems.rs b/crates/bevy_mod_scripting_core/src/systems.rs index 1ce4f340..d7512a41 100644 --- a/crates/bevy_mod_scripting_core/src/systems.rs +++ b/crates/bevy_mod_scripting_core/src/systems.rs @@ -33,6 +33,7 @@ pub fn script_add_synchronizer( script_assets: Res>, mut contexts: ResMut>, mut event_writer: EventWriter, + mut error_writer: EventWriter, ) { debug!("Handling addition/modification of scripts"); @@ -47,6 +48,7 @@ pub fn script_add_synchronizer( &mut providers, &mut contexts, &mut event_writer, + &mut error_writer, ) }) } else { @@ -84,6 +86,7 @@ pub fn script_add_synchronizer( &mut providers, &mut contexts, &mut event_writer, + &mut error_writer, ) } } @@ -120,6 +123,7 @@ pub fn script_hot_reload_handler( mut providers: ResMut>, mut contexts: ResMut>, mut event_writer: EventWriter, + mut error_writer: EventWriter, ) { for e in events.read() { let (handle, created) = match e { @@ -147,6 +151,7 @@ pub fn script_hot_reload_handler( &mut providers, &mut contexts, &mut event_writer, + &mut error_writer, ); } } From 071036f7d730217d512f3634ef1cb8a9b9b17bc7 Mon Sep 17 00:00:00 2001 From: makspll Date: Sat, 7 Sep 2024 19:51:42 +0100 Subject: [PATCH 2/4] formatting --- crates/bevy_mod_scripting_core/src/hosts.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/bevy_mod_scripting_core/src/hosts.rs b/crates/bevy_mod_scripting_core/src/hosts.rs index 43215dd4..1225782a 100644 --- a/crates/bevy_mod_scripting_core/src/hosts.rs +++ b/crates/bevy_mod_scripting_core/src/hosts.rs @@ -7,12 +7,12 @@ use std::{ }; use crate::{ - ScriptErrorEvent, asset::CodeAsset, docs::DocFragment, error::ScriptError, event::{ScriptEvent, ScriptLoaded}, world::WorldPointer, + ScriptErrorEvent, }; /// Describes the target set of scripts this event should From 51d172cc57915e939d6c776445fcf99f84f25ad3 Mon Sep 17 00:00:00 2001 From: makspll Date: Sat, 7 Sep 2024 19:54:44 +0100 Subject: [PATCH 3/4] clippy overrides --- clippy.toml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/clippy.toml b/clippy.toml index cbc4ecce..9eacb815 100644 --- a/clippy.toml +++ b/clippy.toml @@ -1 +1,2 @@ -type-complexity-threshold=1000 \ No newline at end of file +type-complexity-threshold = 1000 +allow = ["type_complexity", "too_many_arguments"] From f0cb158b330b511aa9249a940351b9fe2a612736 Mon Sep 17 00:00:00 2001 From: makspll Date: Sat, 7 Sep 2024 21:22:02 +0100 Subject: [PATCH 4/4] properly fix clippy errors --- clippy.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clippy.toml b/clippy.toml index 9eacb815..aca2b0af 100644 --- a/clippy.toml +++ b/clippy.toml @@ -1,2 +1,2 @@ type-complexity-threshold = 1000 -allow = ["type_complexity", "too_many_arguments"] +too-many-arguments-threshold = 999