0
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-03-10 06:07:03 -04:00
deno/ext/canvas/error.rs
Hajime-san 77703e8ba2 handling unsuportted situation
- adding `DOMExceptionInvalidStateError` in global due to handling not supported image format
- animation image is not supported currently
2024-08-31 05:53:23 +09:00

30 lines
721 B
Rust

// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
use deno_core::error::AnyError;
use std::fmt;
#[derive(Debug)]
pub struct DOMExceptionInvalidStateError {
pub msg: String,
}
impl DOMExceptionInvalidStateError {
pub fn new(msg: &str) -> Self {
DOMExceptionInvalidStateError {
msg: msg.to_string(),
}
}
}
impl fmt::Display for DOMExceptionInvalidStateError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.pad(&self.msg)
}
}
impl std::error::Error for DOMExceptionInvalidStateError {}
pub fn get_error_class_name(e: &AnyError) -> Option<&'static str> {
e.downcast_ref::<DOMExceptionInvalidStateError>()
.map(|_| "DOMExceptionInvalidStateError")
}