Skip to content

Commit 4370b80

Browse files
committed
Removed unwrap when searching for script env
1 parent ae1f414 commit 4370b80

File tree

1 file changed

+6
-3
lines changed
  • crates/languages/bevy_mod_scripting_lua/src

1 file changed

+6
-3
lines changed

crates/languages/bevy_mod_scripting_lua/src/lib.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -261,11 +261,14 @@ pub fn lua_handler(
261261
w.resource::<ScriptEnvironmentStore>()
262262
.map
263263
.get(script_id)
264-
.unwrap()
265-
.clone()
264+
.ok_or(ScriptError::new(format!(
265+
"Could not find environment for script with ScriptId: {}",
266+
script_id
267+
)))
268+
.cloned()
266269
})?;
267270

268-
let handler: Function = match env.raw_get(callback_label.as_ref()) {
271+
let handler: Function = match env?.raw_get(callback_label.as_ref()) {
269272
Ok(handler) => handler,
270273
// not subscribed to this event type
271274
Err(_) => {

0 commit comments

Comments
 (0)