summaryrefslogtreecommitdiff
path: root/ext/cache/lib.rs
diff options
context:
space:
mode:
authorhaturau <135221985+haturatu@users.noreply.github.com>2024-11-20 01:20:47 +0900
committerGitHub <noreply@github.com>2024-11-20 01:20:47 +0900
commit85719a67e59c7aa45bead26e4942d7df8b1b42d4 (patch)
treeface0aecaac53e93ce2f23b53c48859bcf1a36ec /ext/cache/lib.rs
parent67697bc2e4a62a9670699fd18ad0dd8efc5bd955 (diff)
parent186b52731c6bb326c4d32905c5e732d082e83465 (diff)
Merge branch 'denoland:main' into main
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 {