Skip to main content

bitwarden_error/
wasm.rs

1use wasm_bindgen::prelude::*;
2
3/// `name` of the JavaScript `Error` thrown when a value cannot cross the boundary, in either
4/// direction. Narrow on it from TypeScript with `error.name === "SdkConversionError"`.
5pub const CONVERSION_ERROR_NAME: &str = "SdkConversionError";
6
7#[allow(missing_docs)]
8#[cfg_attr(feature = "wasm", wasm_bindgen)]
9extern "C" {
10    #[wasm_bindgen(js_name = Error)]
11    pub type SdkJsError;
12
13    #[wasm_bindgen(constructor, js_class = Error)]
14    pub fn new(message: String) -> SdkJsError;
15
16    #[wasm_bindgen(method, getter, structural)]
17    pub fn message(this: &SdkJsError) -> String;
18
19    #[wasm_bindgen(method, getter, structural)]
20    pub fn name(this: &SdkJsError) -> String;
21
22    #[wasm_bindgen(method, setter, structural)]
23    pub fn set_name(this: &SdkJsError, name: String);
24
25    #[wasm_bindgen(method, getter, structural)]
26    pub fn variant(this: &SdkJsError) -> String;
27
28    #[wasm_bindgen(method, setter, structural)]
29    pub fn set_variant(this: &SdkJsError, variant: String);
30}