1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
use derive_more::From;
use displaydoc::Display;
use thiserror::Error;
use wasm_bindgen::JsValue;
#[derive(Debug, Display, Error, From)]
pub enum Error {
#[from(ignore)]
ChildElementNotFound(&'static str),
#[from(ignore)]
DomElementNotFound(&'static str),
#[from(ignore)]
ElementIdNotFound(&'static str),
FirstElementNotFound,
DynRefFailed,
NotHtmlElement,
NotEventTarget,
NoDocumentElement,
#[from(ignore)]
NoValue(&'static str),
#[from(ignore)]
CannotRemoveAttribute(String),
SelectorsParserError,
JsValue(JsValue),
}
impl Into<JsValue> for Error {
fn into(self) -> JsValue {
match self {
Error::JsValue(value) => value,
_ => JsValue::from_str(&self.to_string()),
}
}
}