use crate::Event;
use derive_more::From;
use displaydoc::Display;
use thiserror::Error;
use wasm_bindgen::JsValue;
#[derive(Debug, Display, Error, From)]
pub enum Error {
#[from(ignore)]
CannotRemoveAttribute(String),
#[from(ignore)]
ChildElementNotFound(&'static str),
#[from(ignore)]
DomElementNotFound(&'static str),
DynRefFailed,
#[from(ignore)]
ElementIdNotFound(&'static str),
EventNotImplemented(Event),
#[from(ignore)]
EventNotHandled(Event),
FirstElementNotFound,
NotHtmlElement,
NotEventTarget,
NoDocumentElement,
NoTargetElement,
#[from(ignore)]
NoValue(&'static str),
SelectorsParserError,
JsValue(JsValue),
}
impl Into<JsValue> for Error {
fn into(self) -> JsValue {
match self {
Error::JsValue(value) => value,
_ => JsValue::from_str(&self.to_string()),
}
}
}