Skip to content

Commit

Permalink
fix: wrap r2 get call with try catch
Browse files Browse the repository at this point in the history
  • Loading branch information
vasco-santos committed Jul 7, 2022
1 parent dbb6ec9 commit 784bfbd
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions packages/api/src/perma-cache/get.js
Expand Up @@ -19,9 +19,13 @@ export async function permaCacheGet(request, env) {
const normalizedUrl = getNormalizedUrl(sourceUrl, env)
const r2Key = normalizedUrl.toString()

const r2Object = await env.SUPERHOT.get(r2Key)
if (r2Object) {
return new Response(r2Object.body)
try {
const r2Object = await env.SUPERHOT.get(r2Key)
if (r2Object) {
return new Response(r2Object.body)
}
} catch (_) {
throw new UrlNotFoundError()
}

throw new UrlNotFoundError()
Expand Down

0 comments on commit 784bfbd

Please sign in to comment.