Skip to main content

qudag_wasm/
error.rs

1//! Error types for WASM bindings
2
3use thiserror::Error;
4use wasm_bindgen::JsError;
5
6#[derive(Error, Debug)]
7pub enum WasmError {
8    #[error("Crypto error: {0}")]
9    CryptoError(String),
10    
11    #[error("Invalid input: {0}")]
12    InvalidInput(String),
13    
14    #[error("Operation failed: {0}")]
15    OperationFailed(String),
16    
17    #[error("Not implemented: {0}")]
18    NotImplemented(String),
19}
20
21impl WasmError {
22    pub fn to_js_error(self) -> JsError {
23        JsError::new(&self.to_string())
24    }
25}