summaryrefslogtreecommitdiff
path: root/ext/cache/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'ext/cache/lib.rs')
-rw-r--r--ext/cache/lib.rs8
1 files changed, 5 insertions, 3 deletions
diff --git a/ext/cache/lib.rs b/ext/cache/lib.rs
index 08661c349..524d4cea0 100644
--- a/ext/cache/lib.rs
+++ b/ext/cache/lib.rs
@@ -28,12 +28,14 @@ pub enum CacheError {
Resource(deno_core::error::AnyError),
#[error(transparent)]
Other(deno_core::error::AnyError),
- #[error(transparent)]
+ #[error("{0}")]
Io(#[from] std::io::Error),
}
#[derive(Clone)]
-pub struct CreateCache<C: Cache + 'static>(pub Arc<dyn Fn() -> C>);
+pub struct CreateCache<C: Cache + 'static>(
+ pub Arc<dyn Fn() -> Result<C, CacheError>>,
+);
deno_core::extension!(deno_cache,
deps = [ deno_webidl, deno_web, deno_url, deno_fetch ],
@@ -231,7 +233,7 @@ where
if let Some(cache) = state.try_borrow::<CA>() {
Ok(cache.clone())
} else if let Some(create_cache) = state.try_borrow::<CreateCache<CA>>() {
- let cache = create_cache.0();
+ let cache = create_cache.0()?;
state.put(cache);
Ok(state.borrow::<CA>().clone())
} else {