Skip to content

Commit be8b307

Browse files
committed
improved error message
1 parent e26353c commit be8b307

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

fyrox-impl/src/engine/mod.rs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ use crate::{
113113
use fxhash::{FxHashMap, FxHashSet};
114114
use fyrox_animation::AnimationTracksData;
115115
use fyrox_core::dyntype::DynTypeConstructorContainer;
116+
use fyrox_core::NameProvider;
116117
use fyrox_graphics::server::SharedGraphicsServer;
117118
use fyrox_graphics_gl::server::GlGraphicsServer;
118119
use fyrox_sound::{
@@ -1018,7 +1019,15 @@ impl ScriptProcessor {
10181019
// `on_deinit` could also spawn new nodes, but we won't take those into account on
10191020
// this frame. They'll be correctly handled on next frame.
10201021
if let Err(error) = script.on_deinit(&mut context) {
1021-
err!("An error occurred during on_deinit call. Reason: {error}");
1022+
err!(
1023+
"An error occurred during on_deinit call in {handle} node (name: {}). \
1024+
Reason: {error}",
1025+
context
1026+
.scene
1027+
.graph
1028+
.try_get(handle)
1029+
.map_or("<undefined>", |n| n.name())
1030+
);
10221031
}
10231032
}
10241033
}
@@ -1244,7 +1253,12 @@ where
12441253
};
12451254

12461255
if let Err(error) = func(&mut script, context) {
1247-
err!("An error occurred during {caller_name} call. Reason: {error}");
1256+
let node = context.node();
1257+
let (handle, name) = node.map_or((Handle::NONE, "<undefined>"), |n| (n.handle(), n.name()));
1258+
err!(
1259+
"An error occurred during {caller_name} call in {handle} node (name: {name}). \
1260+
Reason: {error}",
1261+
);
12481262
}
12491263

12501264
match context.node() {

0 commit comments

Comments
 (0)