Skip to content

Commit

Permalink
Replace panics with CommunicationError::deref_err
Browse files Browse the repository at this point in the history
  • Loading branch information
webmaster128 committed Jun 10, 2020
1 parent b2b426d commit 9bdd795
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/vm/src/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,11 @@ pub fn read_region(ctx: &Ctx, ptr: u32, max_length: usize) -> VmResult<Vec<u8>>
}
Ok(result)
}
None => panic!(
None => Err(CommunicationError::deref_err(region.offset, format!(
"Error dereferencing region {:?} in wasm memory of size {}. This typically happens when the given pointer does not point to a Region struct.",
region,
memory.size().bytes().0
),
)).into()),
}
}

Expand Down Expand Up @@ -125,11 +125,11 @@ pub fn write_region(ctx: &Ctx, ptr: u32, data: &[u8]) -> VmResult<()> {
set_region(ctx, ptr, region)?;
Ok(())
},
None => panic!(
None => Err(CommunicationError::deref_err(region.offset, format!(
"Error dereferencing region {:?} in wasm memory of size {}. This typically happens when the given pointer does not point to a Region struct.",
region,
memory.size().bytes().0
),
)).into()),
}
}

Expand Down

0 comments on commit 9bdd795

Please sign in to comment.