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 25f82cc
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions packages/api/src/perma-cache/get.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,12 @@ 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()
}

0 comments on commit 25f82cc

Please sign in to comment.