mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-03-16 18:20:51 +00:00
js-sys: Add bindings to URIError
This commit is contained in:
parent
4148d3b4ac
commit
a58c2584b3
@ -2706,6 +2706,25 @@ extern "C" {
|
||||
pub fn byte_offset(this: &Uint32Array) -> u32;
|
||||
}
|
||||
|
||||
// URIError
|
||||
#[wasm_bindgen]
|
||||
extern {
|
||||
/// The URIError object represents an error when a global URI handling
|
||||
/// function was used in a wrong way.
|
||||
///
|
||||
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/URIError
|
||||
#[wasm_bindgen(extends = Error, js_name = URIError)]
|
||||
#[derive(Clone, Debug)]
|
||||
pub type UriError;
|
||||
|
||||
/// The URIError object represents an error when a global URI handling
|
||||
/// function was used in a wrong way.
|
||||
///
|
||||
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/URIError
|
||||
#[wasm_bindgen(constructor, js_class = "URIError")]
|
||||
pub fn new(message: &str) -> UriError;
|
||||
}
|
||||
|
||||
// WeakMap
|
||||
#[wasm_bindgen]
|
||||
extern "C" {
|
||||
|
14
crates/js-sys/tests/wasm/UriError.rs
Normal file
14
crates/js-sys/tests/wasm/UriError.rs
Normal file
@ -0,0 +1,14 @@
|
||||
use wasm_bindgen::JsValue;
|
||||
use wasm_bindgen_test::*;
|
||||
use wasm_bindgen::JsCast;
|
||||
use js_sys::*;
|
||||
|
||||
#[wasm_bindgen_test]
|
||||
fn uri_error() {
|
||||
let error = UriError::new("msg");
|
||||
assert!(error.is_instance_of::<UriError>());
|
||||
assert!(error.is_instance_of::<Error>());
|
||||
|
||||
let base: &Error = error.as_ref();
|
||||
assert_eq!(JsValue::from(base.message()), "msg");
|
||||
}
|
@ -33,6 +33,7 @@ pub mod Set;
|
||||
pub mod SetIterator;
|
||||
pub mod Symbol;
|
||||
pub mod TypedArray;
|
||||
pub mod UriError;
|
||||
pub mod WeakMap;
|
||||
pub mod WeakSet;
|
||||
pub mod WebAssembly;
|
||||
|
Loading…
x
Reference in New Issue
Block a user