Skip to content

Commit

Permalink
Minor refactor to return error earlier
Browse files Browse the repository at this point in the history
  • Loading branch information
RoyalIcing committed Apr 3, 2024
1 parent 42f4e3d commit 85004c7
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions native/wasmex/src/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,15 @@ pub fn get_global_value(
)))
})?);

let global_val = instance
let global = instance
.get_global(&mut store_or_caller, &global_name)
.map(|g| g.get(&mut store_or_caller));
.ok_or_else(|| {
rustler::Error::Term(Box::new(format!(
"exported global `{global_name}` not found"
)))
})?;

let value = global_val.ok_or_else(|| {
rustler::Error::Term(Box::new(format!(
"exported global `{global_name}` not found"
)))
})?;
let value = global.get(&mut store_or_caller);

match value {
Val::I32(i) => Ok(i.encode(env)),
Expand Down

0 comments on commit 85004c7

Please sign in to comment.