summaryrefslogtreecommitdiff
path: root/runtime/errors.rs
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/errors.rs')
-rw-r--r--runtime/errors.rs14
1 files changed, 14 insertions, 0 deletions
diff --git a/runtime/errors.rs b/runtime/errors.rs
index 476aae63b..59928965b 100644
--- a/runtime/errors.rs
+++ b/runtime/errors.rs
@@ -10,6 +10,7 @@
//! exceptions.
use deno_broadcast_channel::BroadcastChannelError;
+use deno_cache::CacheError;
use deno_core::error::AnyError;
use deno_core::serde_json;
use deno_core::url;
@@ -154,6 +155,18 @@ pub fn get_nix_error_class(error: &nix::Error) -> &'static str {
}
}
+pub fn get_cache_error(error: &CacheError) -> &'static str {
+ match error {
+ CacheError::Sqlite(_) => "Error",
+ CacheError::JoinError(_) => "Error",
+ CacheError::Resource(err) => {
+ deno_core::error::get_custom_error_class(err).unwrap_or("Error")
+ }
+ CacheError::Other(e) => get_error_class_name(e).unwrap_or("Error"),
+ CacheError::Io(err) => get_io_error_class(err),
+ }
+}
+
fn get_broadcast_channel_error(error: &BroadcastChannelError) -> &'static str {
match error {
BroadcastChannelError::Resource(err) => {
@@ -173,6 +186,7 @@ pub fn get_error_class_name(e: &AnyError) -> Option<&'static str> {
.or_else(|| deno_web::get_error_class_name(e))
.or_else(|| deno_webstorage::get_not_supported_error_class_name(e))
.or_else(|| deno_websocket::get_network_error_class_name(e))
+ .or_else(|| e.downcast_ref::<CacheError>().map(get_cache_error))
.or_else(|| {
e.downcast_ref::<BroadcastChannelError>()
.map(get_broadcast_channel_error)