diff options
Diffstat (limited to 'extensions/web/lib.rs')
-rw-r--r-- | extensions/web/lib.rs | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/extensions/web/lib.rs b/extensions/web/lib.rs index 0d2dbbd78..7fa809776 100644 --- a/extensions/web/lib.rs +++ b/extensions/web/lib.rs @@ -1,7 +1,9 @@ // Copyright 2018-2021 the Deno authors. All rights reserved. MIT license. +use deno_core::error::AnyError; use deno_core::include_js_files; use deno_core::Extension; +use std::fmt; use std::path::PathBuf; /// Load and execute the javascript code. @@ -24,3 +26,31 @@ pub fn init() -> Extension { pub fn get_declaration() -> PathBuf { PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("lib.deno_web.d.ts") } + +#[derive(Debug)] +pub struct DomExceptionQuotaExceededError { + pub msg: String, +} + +impl DomExceptionQuotaExceededError { + pub fn new(msg: &str) -> Self { + DomExceptionQuotaExceededError { + msg: msg.to_string(), + } + } +} + +impl fmt::Display for DomExceptionQuotaExceededError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad(&self.msg) + } +} + +impl std::error::Error for DomExceptionQuotaExceededError {} + +pub fn get_quota_exceeded_error_class_name( + e: &AnyError, +) -> Option<&'static str> { + e.downcast_ref::<DomExceptionQuotaExceededError>() + .map(|_| "DOMExceptionQuotaExceededError") +} |