Files
breez-sdk-liquid/lib/wasm/src/error.rs
Daniel Granhão 09138c9d45 Wasm: wallet cache persistence (#868)
* Expose wallet cache persister

* Implement IndexedDB wallet cache persister

* Refactor wallet persister interfaces

* Implement Node Fs persister

* Encrypt wallet updates

* Remove unnecessary tokio_with_wasm features

* Improve async persist logs

* Fix flutter binding generation

* Use dynamic dispatch for wallet_cache_persister

* Optimize conditional compilation branching

* Address review

* Refactor structure
2025-04-10 14:46:16 +01:00

55 lines
1.1 KiB
Rust

use breez_sdk_liquid::{
error::{PaymentError, SdkError},
signer::{NewError, SignError},
LnUrlAuthError, LnUrlPayError, LnUrlWithdrawError,
};
use std::fmt::Display;
use wasm_bindgen::{JsError, JsValue};
#[derive(Clone, Debug)]
pub struct WasmError(JsValue);
impl WasmError {
pub fn new<T: Display>(val: T) -> Self {
WasmError(JsValue::from(format!("{}", val)))
}
}
impl From<WasmError> for JsValue {
fn from(err: WasmError) -> Self {
err.0
}
}
impl From<JsValue> for WasmError {
fn from(err: JsValue) -> Self {
Self(err)
}
}
macro_rules! wasm_error_wrapper {
($($t:ty),*) => {
$(
impl From<$t> for WasmError {
fn from(err: $t) -> Self {
WasmError(JsError::new(format!("{}", err).as_str()).into())
}
}
)*
}
}
wasm_error_wrapper!(
anyhow::Error,
LnUrlAuthError,
LnUrlPayError,
LnUrlWithdrawError,
log::ParseLevelError,
PaymentError,
SdkError,
NewError,
SignError,
&str,
String
);