//! Error handling for WASM bindings.
//!
//! Maps errors to JavaScript exceptions with human-readable messages.

use wasm_bindgen::JsValue;

/// Convert a Result to a Result with JsValue error.
pub fn result_to_js<T, E: std::fmt::Display>(result: Result<T, E>) -> Result<T, JsValue> {
    result.map_err(|e| js_sys::Error::new(&e.to_string()).into())
}
