mirror of
https://github.com/mii443/wasmer.git
synced 2025-12-13 13:58:38 +00:00
Added custom error test
This commit is contained in:
@@ -80,7 +80,7 @@ macro_rules! impl_native_traits {
|
||||
let results = self.exported.function.apply(
|
||||
&JsValue::UNDEFINED,
|
||||
&Array::from_iter(params_list.iter())
|
||||
).unwrap();
|
||||
)?;
|
||||
let mut rets_list_array = Rets::empty_array();
|
||||
let mut_rets = rets_list_array.as_mut() as *mut [i128] as *mut i128;
|
||||
match Rets::size() {
|
||||
|
||||
@@ -2,8 +2,10 @@
|
||||
use std::error::Error;
|
||||
use std::fmt;
|
||||
use std::sync::Arc;
|
||||
use std::convert::TryInto;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::JsValue;
|
||||
use wasm_bindgen::JsCast;
|
||||
|
||||
/// A struct representing an aborted instruction execution, with a message
|
||||
/// indicating the cause.
|
||||
@@ -57,8 +59,13 @@ impl RuntimeError {
|
||||
|
||||
/// Raises a custom user Error
|
||||
pub fn raise(error: Box<dyn Error + Send + Sync>) -> ! {
|
||||
let error = RuntimeError {
|
||||
inner: Arc::new(RuntimeErrorSource::User(error)),
|
||||
let error = if error.is::<RuntimeError>() {
|
||||
*error.downcast::<RuntimeError>().unwrap()
|
||||
}
|
||||
else {
|
||||
RuntimeError {
|
||||
inner: Arc::new(RuntimeErrorSource::User(error)),
|
||||
}
|
||||
};
|
||||
let js_error: JsValue = error.into();
|
||||
wasm_bindgen::throw_val(js_error)
|
||||
@@ -119,11 +126,18 @@ impl From<JsValue> for RuntimeError {
|
||||
RuntimeError {
|
||||
inner: Arc::new(RuntimeErrorSource::Js(original)),
|
||||
}
|
||||
// let into_runtime: Result<RuntimeError, _> = original.clone().try_into();
|
||||
// match into_runtime {
|
||||
// Ok(rt) => rt,
|
||||
// Err(_) => RuntimeError {
|
||||
// inner: Arc::new(RuntimeErrorSource::Js(original)),
|
||||
// }
|
||||
// }
|
||||
// match original.dyn_into::<RuntimeError>() {
|
||||
// Ok(rt) => rt,
|
||||
// Err(original) => RuntimeError {
|
||||
// inner: Arc::new(RuntimeErrorSource::Js(original)),
|
||||
// }
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
// impl Into<JsValue> for RuntimeError {
|
||||
// fn into(self) -> JsValue {
|
||||
|
||||
// }
|
||||
// }
|
||||
|
||||
Reference in New Issue
Block a user