error.rs 288 B

123456789101112
  1. use wasm_bindgen::JsValue;
  2. pub type Result<T, E = JsValue> = std::result::Result<T, E>;
  3. /// Helper to replace the `E` to `Error` to `napi::Error` conversion.
  4. #[inline]
  5. pub fn into_err<E>(error: E) -> JsValue
  6. where
  7. E: std::fmt::Display,
  8. {
  9. JsValue::from_str(&error.to_string())
  10. }