Skip to content

Commit

Permalink
Log error if failed to fetch remote image (#5393)
Browse files Browse the repository at this point in the history
* I cant catch an error in the loadRemoteImage function when the fetch function occurs error

* I cant catch an error in the loadRemoteImage function when the fetch function occurs error

* fix ssg file

Co-authored-by: wuls <linsheng.wu@beantechs.com>
Co-authored-by: Okiki Ojo <okikio.dev@gmail.com>
  • Loading branch information
3 people authored Nov 16, 2022
1 parent aa16b6c commit e2fb0c4
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/tough-doors-shop.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@astrojs/image': patch
---

Log error if failed to fetch remote image
3 changes: 2 additions & 1 deletion packages/integrations/image/src/build/ssg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ async function loadRemoteImage(src: string) {
data: Buffer.from(await res.arrayBuffer()),
expires: Date.now() + expires,
};
} catch {
} catch (err: unknown) {
console.error(err)
return undefined;
}
}
Expand Down
3 changes: 2 additions & 1 deletion packages/integrations/image/src/endpoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ async function loadRemoteImage(src: URL) {
}

return Buffer.from(await res.arrayBuffer());
} catch {
} catch (err: unknown) {
console.error(err)
return undefined;
}
}
Expand Down

0 comments on commit e2fb0c4

Please sign in to comment.