Skip to main content

wasm_toolkit/
errors.rs

1pub type WasmToolkitResult<T> = Result<T, WasmToolkitError>;
2
3#[derive(Debug, PartialEq, Eq, Clone, thiserror::Error)]
4pub enum WasmToolkitError {
5    #[error("The `Window` was not found, are you running the program in a browser environment?")]
6    WindowNotFound,
7    #[error("The `Document` was not found, are you running the program in a browser environment?")]
8    DocumentNotFound,
9    #[error("The host was not found from `window.location.host`. Error: `{0}`.")]
10    HostNotFound(String),
11    #[error("The origin was not found from `window.location.origin`. Error: `{0}`.")]
12    OriginNotFound(String),
13    #[error("The hostname was not found from `window.location.hostname`. Error: `{0}`.")]
14    HostnameNotFound(String),
15    #[error("The protocol was not found from `window.location.protocol`. Error: `{0}`.")]
16    ProtocolNotFound(String),
17    #[error("The port was not found from `window.location.port`. Error: `{0}`.")]
18    PortNotFound(String),
19    #[error("The href was not found from `window.location.href`. Error: `{0}`.")]
20    HrefNotFound(String),
21    #[error("The hash was not found from `window.location.hash`. Error: `{0}`.")]
22    HashNotFound(String),
23    #[error("Could not stringify JsValue to as JsString")]
24    UnableToStringifyJsValue,
25    #[error("The JsValue is not a valid JsString or it is valid but not UTF-8")]
26    JsStringNotValid,
27    #[error("Unable to get the browser language from `window.navigator.language`")]
28    BrowserLanguageNotFound,
29    #[error("`window.matchMedia` query is unsupported!")]
30    MatchMediaQueryUnsupported,
31    #[error("{0}")]
32    Op(String),
33    #[error("`.addEventListener` error: `{0}`")]
34    AddEventListener(String),
35    #[error("`window.document.documentElement` is missing!")]
36    MissingDocumentElement,
37    #[error("Unable to case `window.document.documentElement` to `web_sys::HtmlElement`")]
38    UnableToCastElementToHtmlElement,
39    #[error("Unable to set a CSS property")]
40    UnableToSetCssProperty,
41}