pub enum WasmError {
ParseError(String),
QueryError(String),
StoreError(String),
ValidationError(String),
SerializationError(String),
NotImplemented(String),
}Expand description
WASM error type
Variants§
ParseError(String)
QueryError(String)
StoreError(String)
ValidationError(String)
SerializationError(String)
NotImplemented(String)
Implementations§
Source§impl WasmError
impl WasmError
Sourcepub fn code(&self) -> &'static str
pub fn code(&self) -> &'static str
A stable, machine-readable name for this error’s variant.
This is set as both the name and code properties of the
js_sys::Error built by From<WasmError> for JsValue, so a JS
catch block can branch on error kind (err.code === "ParseError")
instead of pattern-matching the human-readable message text.
Trait Implementations§
Source§impl Error for WasmError
impl Error for WasmError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
Source§impl From<WasmError> for JsValue
Convert a WasmError into a real js_sys::Error (so JS sees
instanceof Error with a stack trace) carrying a stable name/code so
callers can distinguish a ParseError from a StoreError from a
ValidationError etc. without parsing the message string.
impl From<WasmError> for JsValue
Convert a WasmError into a real js_sys::Error (so JS sees
instanceof Error with a stack trace) carrying a stable name/code so
callers can distinguish a ParseError from a StoreError from a
ValidationError etc. without parsing the message string.
js_sys::Error::new calls into an imported JS binding that only exists
when actually running inside a wasm32 + JS host — calling it from a
native (non-wasm32) test binary panics with “cannot call wasm-bindgen
imported functions on non-wasm targets”. Since this crate’s own design
keeps its Rust-level logic natively testable (see api::wasm_api’s module
doc), non-wasm32 builds fall back to the plain string this conversion
used before, so cargo test/cargo nextest keeps working; only real
wasm32 builds — the only place a JS catch block ever actually sees
this value — get the richer js_sys::Error.