Add error to JsValue conversion and example (#691)

This commit is contained in:
John Gallagher
2019-10-30 16:30:32 -04:00
committed by Sean McArthur
parent 57300edbc4
commit 43f2ff083c
9 changed files with 6224 additions and 0 deletions

View File

@@ -170,6 +170,20 @@ impl StdError for Error {
}
}
#[cfg(target_arch = "wasm32")]
impl From<crate::error::Error> for wasm_bindgen::JsValue {
fn from(err: Error) -> wasm_bindgen::JsValue {
js_sys::Error::from(err).into()
}
}
#[cfg(target_arch = "wasm32")]
impl From<crate::error::Error> for js_sys::Error {
fn from(err: Error) -> js_sys::Error {
js_sys::Error::new(&format!("{}", err))
}
}
#[derive(Debug)]
pub(crate) enum Kind {
Builder,