web_wt_sys/webtransport/web_transport_error.rs
1//! [`WebTransportError`]
2//!
3//! <https://w3c.github.io/webtransport/#web-transport-error-interface>
4
5use js_sys::Object;
6use wasm_bindgen::prelude::*;
7use web_sys::DomException;
8
9use super::*;
10
11#[wasm_bindgen]
12extern "C" {
13 ///The `WebTransportError` interface.
14 ///
15 /// <https://w3c.github.io/webtransport/#webtransporterror>
16 #[wasm_bindgen(extends = DomException, extends = Object)]
17 #[derive(Debug, Clone, PartialEq, Eq)]
18 pub type WebTransportError;
19
20 /// ```webidl
21 /// constructor(optional DOMString message = "", optional WebTransportErrorOptions options = {});
22 /// ```
23 ///
24 /// <https://w3c.github.io/webtransport/#dom-webtransporterror-webtransporterror>
25 #[wasm_bindgen(constructor)]
26 pub fn new() -> WebTransportError;
27
28 /// Create an error that carries the given options.
29 ///
30 /// Both Chrome 154 and Firefox 154 implement the earlier revision of
31 /// the constructor, which takes the options as its only argument under
32 /// the `WebTransportErrorInit` name:
33 ///
34 /// ```webidl
35 /// constructor(optional WebTransportErrorInit init = {});
36 /// ```
37 ///
38 /// Calling them with the message and the options as two arguments - as
39 /// the current spec defines - throws a `TypeError`, so this is the only
40 /// way to construct an error with a `streamErrorCode` today.
41 ///
42 /// <https://w3c.github.io/webtransport/#dom-webtransporterror-webtransporterror>
43 #[wasm_bindgen(constructor)]
44 pub fn new_with_init(init: &WebTransportErrorOptions) -> WebTransportError;
45
46 /// ```webidl
47 /// readonly attribute WebTransportErrorSource source;
48 /// ```
49 ///
50 /// <https://w3c.github.io/webtransport/#dom-webtransporterror-source>
51 #[wasm_bindgen(method, getter)]
52 pub fn source(this: &WebTransportError) -> WebTransportErrorSource;
53
54 /// ```webidl
55 /// readonly attribute unsigned long? streamErrorCode;
56 /// ```
57 ///
58 /// <https://w3c.github.io/webtransport/#dom-webtransporterror-streamerrorcode>
59 #[wasm_bindgen(method, getter = streamErrorCode)]
60 pub fn stream_error_code(this: &WebTransportError) -> Option<u32>;
61}