Trait MapJsError

Source
pub trait MapJsError<T> {
    // Required method
    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§

Source

fn map_err_to_js(self) -> Result<T, JsValue>

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§

Source§

impl<T, E: ToString> MapJsError<T> for Result<T, E>

Implementors§