karma_p2p_wasm/error.rs
1use wasm_bindgen::JsValue;
2
3#[derive(Debug)]
4pub enum Error {
5 ErrAddrType,
6 WebsysError(JsValue),
7 SerdeError(serde_json::Error),
8}
9
10impl From<serde_json::Error> for Error {
11 fn from(e: serde_json::Error) -> Self {
12 Error::SerdeError(e)
13 }
14}
15
16impl From<JsValue> for Error {
17 fn from(e: JsValue) -> Self {
18 Error::WebsysError(e)
19 }
20}
21
22pub type Result<T> = core::result::Result<T, Error>;