Skip to content

Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation

359 B
Raw Blame
use wasm_bindgen::prelude::*;

pub trait JsResultExt<T> {
    fn err_to_js(self) -> Result<T, JsValue>;
}

impl<T, E> JsResultExt<T> for Result<T, E>
where
    E: serde::Serialize,
{
    fn err_to_js(self) -> Result<T, JsValue> {
        match self {
            Ok(t) => Ok(t),
            Err(e) => Err(serde_wasm_bindgen::to_value(&e)?),
        }
    }
}