aboutsummaryrefslogtreecommitdiffstats
path: root/src/error.rs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/error.rs25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/error.rs b/src/error.rs
index 717dfdd..4976a78 100644
--- a/src/error.rs
+++ b/src/error.rs
@@ -7,6 +7,8 @@ use std::{
};
use thiserror::Error;
+#[cfg(target_arch = "wasm32")]
+use wasm_bindgen::JsValue;
use crate::{
element::{Content, Name, NamespaceDeclaration},
@@ -72,6 +74,29 @@ pub enum Error {
Deserialize(#[from] DeserializeError),
#[error("root element has already been fully processed")]
RootElementEnded,
+ #[cfg(target_arch = "wasm32")]
+ #[error("websocket error: {0}")]
+ Websocket(#[from] WebsocketError),
+}
+
+#[cfg(target_arch = "wasm32")]
+#[derive(Error, Debug, Clone)]
+pub enum WebsocketError {
+ #[error("write: {0:?}")]
+ Write(JsValue),
+ #[error("invalid encoding")]
+ InvalidEncoding,
+ #[error("can't decode blob")]
+ CantDecodeBlob,
+ #[error("unknown data type")]
+ UnknownDataType,
+}
+
+#[cfg(target_arch = "wasm32")]
+impl From<JsValue> for Error {
+ fn from(e: JsValue) -> Self {
+ Self::Websocket(WebsocketError::Write(e))
+ }
}
impl From<std::io::Error> for Error {