pub trait MapJsError<T> {
    fn map_err_to_js(self) -> Result<T, JsValue>;
}
Expand description

An extension trait on Result that helps easy conversion of Rust errors to JavaScript error strings usable by wasm_bindgen

Required Methods

An extension method on Result to easily convert Rust errors to JavaScript ones.

#[wasm_bindgen]
pub fn method(&self) -> Result<JsSomething, JsValue> {
    let result: JsSomething = self.fallible().map_err_to_js()?;
    Ok(result)
}

Implementations on Foreign Types

Implementors