diff --git a/src/storage/images.ts b/src/storage/images.ts index 7e10ee9..bac9c02 100644 --- a/src/storage/images.ts +++ b/src/storage/images.ts @@ -7,6 +7,12 @@ export async function downloadAttachment( filename: string, ): Promise { const response = await fetch(url); + if (!response.ok) { + throw new Error( + `Failed to download attachment: HTTP ${response.status} ${response.statusText}`, + ); + } + const buffer = Buffer.from(await response.arrayBuffer()); const filePath = path.join(IMAGES_DIR, filename); fs.writeFileSync(filePath, buffer);