Skip to content

Commit 9bdd795

Browse files
committed
Replace panics with CommunicationError::deref_err
1 parent b2b426d commit 9bdd795

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

packages/vm/src/memory.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,11 @@ pub fn read_region(ctx: &Ctx, ptr: u32, max_length: usize) -> VmResult<Vec<u8>>
8383
}
8484
Ok(result)
8585
}
86-
None => panic!(
86+
None => Err(CommunicationError::deref_err(region.offset, format!(
8787
"Error dereferencing region {:?} in wasm memory of size {}. This typically happens when the given pointer does not point to a Region struct.",
8888
region,
8989
memory.size().bytes().0
90-
),
90+
)).into()),
9191
}
9292
}
9393

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

0 commit comments

Comments
 (0)