build: fix wasm build

This commit is contained in:
鲁树人
2025-05-04 21:15:37 +09:00
parent 91f54423a2
commit 2ac0613192
2 changed files with 5 additions and 20 deletions

1
Cargo.lock generated
View File

@@ -584,7 +584,6 @@ dependencies = [
name = "umc_kuwo"
version = "0.1.9"
dependencies = [
"anyhow",
"byteorder",
"itertools 0.13.0",
"thiserror",

View File

@@ -1,22 +1,8 @@
use wasm_bindgen::JsError;
#[derive(Debug)]
pub struct WasmError {
error: anyhow::Error,
}
impl From<anyhow::Error> for WasmError {
fn from(err: anyhow::Error) -> WasmError {
WasmError { error: err }
}
}
impl From<WasmError> for JsError {
fn from(error: WasmError) -> Self {
JsError::new(&error.error.to_string())
}
}
pub fn map_js_error(error: anyhow::Error) -> wasm_bindgen::JsError {
JsError::new(&error.to_string())
pub fn map_js_error<T>(error: T) -> JsError
where
T: std::fmt::Debug + std::fmt::Display,
{
JsError::new(error.to_string().as_str())
}