Renamed RuntimeError::from_jit to RuntimeError::from_trap

This commit is contained in:
Syrus
2020-04-30 02:14:24 -07:00
parent ca1b0ee565
commit 05ea566d48
3 changed files with 7 additions and 6 deletions

View File

@@ -310,7 +310,7 @@ impl Table {
src_index,
len,
)
.map_err(|e| RuntimeError::from_jit(e))?;
.map_err(|e| RuntimeError::from_trap(e))?;
Ok(())
}
@@ -620,7 +620,7 @@ impl Func {
values_vec.as_mut_ptr() as *mut u8,
)
} {
return Err(RuntimeError::from_jit(error));
return Err(RuntimeError::from_trap(error));
}
// Load the return values out of `values_vec`.

View File

@@ -306,7 +306,7 @@ impl CompiledModule {
is_bulk_memory,
host_state,
)
.map_err(|trap| InstantiationError::Start(RuntimeError::from_jit(trap)))
.map_err(|trap| InstantiationError::Start(RuntimeError::from_trap(trap)))
}
/// Return a reference-counting pointer to a module.

View File

@@ -26,7 +26,7 @@ impl RuntimeError {
/// Creates a new `Trap` with `message`.
/// # Example
/// ```
/// let trap = wasmer_runtime::RuntimeError::new("unexpected error");
/// let trap = wasmer_jit::RuntimeError::new("unexpected error");
/// assert_eq!("unexpected error", trap.message());
/// ```
pub fn new<I: Into<String>>(message: I) -> Self {
@@ -35,7 +35,7 @@ impl RuntimeError {
}
/// Create a new RuntimeError from a Trap.
pub fn from_jit(jit: Trap) -> Self {
pub fn from_trap(trap: Trap) -> Self {
let info = FRAME_INFO.read().unwrap();
match jit {
Trap::User(error) => {
@@ -43,6 +43,7 @@ impl RuntimeError {
// theory) we should only see user errors which were originally
// created from our own `Trap` type (see the trampoline module
// with functions).
// Self::new(format!("{}", error))
*error.downcast().expect("only `Trap` errors are supported")
}
Trap::Jit { pc, backtrace } => {
@@ -187,6 +188,6 @@ impl std::error::Error for RuntimeError {}
impl From<Trap> for RuntimeError {
fn from(trap: Trap) -> Self {
Self::from_jit(trap)
Self::from_trap(trap)
}
}