use super::*;
#[derive(Clone, Debug, PartialEq, PartialOrd)]
#[repr(transparent)]
pub struct DOMException {
inner: Any,
}
impl FromVal for DOMException {
fn from_val(v: &Any) -> Self {
DOMException {
inner: Any::from_val(v),
}
}
fn take_ownership(v: AnyHandle) -> Self {
Self::from_val(&Any::take_ownership(v))
}
fn as_handle(&self) -> AnyHandle {
self.inner.as_handle()
}
}
impl core::ops::Deref for DOMException {
type Target = Any;
fn deref(&self) -> &Self::Target {
&self.inner
}
}
impl core::ops::DerefMut for DOMException {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.inner
}
}
impl AsRef<Any> for DOMException {
fn as_ref(&self) -> &Any {
&self.inner
}
}
impl AsMut<Any> for DOMException {
fn as_mut(&mut self) -> &mut Any {
&mut self.inner
}
}
impl From<DOMException> for Any {
fn from(s: DOMException) -> Any {
let handle = s.inner.as_handle();
core::mem::forget(s);
Any::take_ownership(handle)
}
}
impl From<&DOMException> for Any {
fn from(s: &DOMException) -> Any {
s.inner.clone().into()
}
}
jsbind::utils::impl_dyn_cast!(DOMException);
impl DOMException {
pub fn name(&self) -> JsString {
self.inner.get("name").as_::<JsString>()
}
}
impl DOMException {
pub fn message(&self) -> JsString {
self.inner.get("message").as_::<JsString>()
}
}
impl DOMException {
pub fn code(&self) -> u16 {
self.inner.get("code").as_::<u16>()
}
}
impl DOMException {
pub fn new() -> DOMException {
Self {
inner: Any::global("DOMException").new(&[]).as_::<Any>(),
}
}
}
impl DOMException {
pub fn new_with_message(message: &JsString) -> DOMException {
Self {
inner: Any::global("DOMException")
.new(&[message.into()])
.as_::<Any>(),
}
}
}
impl DOMException {
pub fn new_with_message_and_name(message: &JsString, name: &JsString) -> DOMException {
Self {
inner: Any::global("DOMException")
.new(&[message.into(), name.into()])
.as_::<Any>(),
}
}
}